<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DB Connect Database Query Ignoring Alias Names and Functions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155429#M185700</link>
    <description>&lt;P&gt;Just a guess, but because that's a time column it might have extra work being applied to it. What happens if you cast it as DATETIME?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jul 2014 02:25:52 GMT</pubDate>
    <dc:creator>jcoates_splunk</dc:creator>
    <dc:date>2014-07-24T02:25:52Z</dc:date>
    <item>
      <title>DB Connect Database Query Ignoring Alias Names and Functions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155428#M185699</link>
      <description>&lt;P&gt;Hey folks,&lt;/P&gt;

&lt;P&gt;I'm running into an issue where the Splunk DB Connect App is not respecting the alias names and through my debugging, also functions.&lt;/P&gt;

&lt;P&gt;My original query tested via MySQL Workbench returns everything as intended.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;SELECT p.bf_description AS ProjectName, s.bf_name AS SelectorName, FROM_UNIXTIME(b.bf_start) AS BuildStart, &lt;BR /&gt;
b.bf_duration AS BuildDuration,b.bf_state, bf_cancelled, b.bf_tag,bf_user_id, b.bf_result AS OverallBuildResult,&lt;BR /&gt;
b.bf_passchain_id, b.bf_failchain_id, bf_chain_id, bf_ischained, b.bf_modified &lt;BR /&gt;
FROM bf_builds b &lt;BR /&gt;
LEFT JOIN bf_projects p &lt;BR /&gt;
ON b.bf_project_id=p.bf_id &lt;BR /&gt;
LEFT JOIN bf_selector s &lt;BR /&gt;
ON  b.bf_selector_id=s.bf_id&lt;BR /&gt;
WHERE b.bf_modified &amp;gt; SUBDATE(NOW(), INTERVAL 1 HOUR)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;My modified query for DB Connect App after various iterations of testing:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
SELECT CAST(p.bf_description AS CHAR(64)) AS ProjectName, s.bf_name AS ServerName, r.bf_result AS Result, r.bf_description AS StepName, r.bf_seq AS StepNumber, FROM_UNIXTIME(r.bf_start) AS StartTime, r.bf_duration AS Duration, (commands.bf_text) AS Commands, r.bf_log_id, r.bf_step_id, r.bf_modified FROM bf_results r LEFT JOIN bf_servers s ON r.bf_server_id=s.bf_id LEFT JOIN bf_builds b ON r.bf_build_id=b.bf_id LEFT JOIN bf_projects p ON b.bf_project_id=p.bf_id LEFT JOIN bf_store commands ON r.bf_command_store=commands.bf_id WHERE r.bf_modified &amp;gt; SUBDATE(NOW(), INTERVAL 1 HOUR)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;In the query above, the only way I can get the DB Connect App to respect Alias names is to use a MySQL function.  For testing purposes, I simply casted a varchar type as an explicit char:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt; CAST(p.bf_description AS CHAR(64)) AS ProjectName &lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This resulted in the returning query to respect the Alias name 'ProjectName'.  Similarly the following code also triggered the DB Connect App to respect the Alias name StartTime:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt; FROM_UNIXTIME(r.bf_start) AS StartTime &lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However, the latter function is supposed to convert the r.bf_start value to a legitimate DateTime return value.  This works in MySQL Workbench, but the DB Connect App returned the original unixtime value.  &lt;/P&gt;

&lt;P&gt;Does anyone have any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:09:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155428#M185699</guid>
      <dc:creator>AvianFLU</dc:creator>
      <dc:date>2020-09-28T17:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: DB Connect Database Query Ignoring Alias Names and Functions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155429#M185700</link>
      <description>&lt;P&gt;Just a guess, but because that's a time column it might have extra work being applied to it. What happens if you cast it as DATETIME?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2014 02:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155429#M185700</guid>
      <dc:creator>jcoates_splunk</dc:creator>
      <dc:date>2014-07-24T02:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: DB Connect Database Query Ignoring Alias Names and Functions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155430#M185701</link>
      <description>&lt;P&gt;Not really an answer, but I found a workaround.  &lt;/P&gt;

&lt;P&gt;Intentionally casting every single column as char will result in the Alias names being respected.  My final query is as follows:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
SELECT CAST(p.bf_description AS char(128)) AS ProjectName, CAST(s.bf_name AS CHAR(32)) AS ServerName, CAST(r.bf_result AS CHAR(1)) AS Result, &lt;BR /&gt;
CAST(r.bf_description AS CHAR(128)) AS StepName, CAST(r.bf_seq AS CHAR(3)) AS StepNumber,  CAST(FROM_UNIXTIME(r.bf_start) AS CHAR(64)) AS StartTime, &lt;BR /&gt;
CAST(r.bf_duration AS CHAR(32)) AS Duration, commands.bf_text AS Commands, r.bf_log_id, r.bf_step_id, CAST(r.bf_modified AS CHAR(64)) AS Modified FROM bf_results r&lt;BR /&gt;
LEFT JOIN bf_servers s&lt;BR /&gt;
ON r.bf_server_id=s.bf_id&lt;BR /&gt;
LEFT JOIN bf_builds b&lt;BR /&gt;
ON r.bf_build_id=b.bf_id&lt;BR /&gt;
LEFT JOIN bf_projects p&lt;BR /&gt;
ON b.bf_project_id=p.bf_id&lt;BR /&gt;
LEFT JOIN bf_store commands&lt;BR /&gt;
ON r.bf_command_store=commands.bf_id&lt;BR /&gt;
WHERE r.bf_modified &amp;gt; SUBDATE(NOW(), INTERVAL 1 HOUR)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:10:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Database-Query-Ignoring-Alias-Names-and-Functions/m-p/155430#M185701</guid>
      <dc:creator>AvianFLU</dc:creator>
      <dc:date>2020-09-28T17:10:38Z</dc:date>
    </item>
  </channel>
</rss>

