Skip to main content

WITH max_tw AS (

  SELECT 

    partition_0 AS "Site", 

    CONCAT(CONCAT(SPLIT_PART(SPLIT_PART("date", ' ', 2),'-',3), '-',

    SPLIT_PART(SPLIT_PART("date", ' ', 2),'-',1), '-',

    SPLIT_PART(SPLIT_PART("date", ' ', 2),'-',2)), ' ',

    TRIM(ELEMENT_AT(SPLIT("date",' '), 1))) AS "Date/Time", 

    (permeate_last_day*100) AS "24Hr TW",

    (filtrate_last_day*100) AS "Pre-Ro TW",

    CAST(mos_tmp AS DECIMAL(15,4)) AS MOS_TMP,

    CAST(mos_ave_permeability AS DECIMAL(15,4)) AS MBR_Perm,

    CAST(ai_ae_buf_01_ph AS DECIMAL(15,4)) AS Buffer_Tank_PH,

    CAST(ai_ae_bio_01_do AS DECIMAL(15,4)) AS Bioreactor_DOX,

    CAST(ai_ae_bio_02_mlss AS DECIMAL(15,4)) AS Bioreactor_MLSS,

    CAST(ai_ae_cct_01_ph AS DECIMAL(15,4)) AS Permeate_PH,

    CAST(ai_ae_cct_02 AS DECIMAL(15,4)) AS FCR_,

    CAST(ai_ae_mbr_03_ph AS DECIMAL(15,4)) AS Membrane_PH,

    CAST(ai_ae_ro_01 AS DECIMAL(15,4)) AS Filtrate_Conductivity,

    CAST(ai_ae_ro_02 AS DECIMAL(15,4)) AS Permeate_Conductivity,

    RANK() OVER (PARTITION BY dt ORDER BY filtrate_last_day DESC, CONCAT(CONCAT(

    SPLIT_PART(SPLIT_PART("date", ' ', 2),'-',3), '-',

    SPLIT_PART(SPLIT_PART("date", ' ', 2),'-',1), '-',

    SPLIT_PART(SPLIT_PART("date", ' ', 2),'-',2)),' ',

    TRIM(ELEMENT_AT(SPLIT("date",' '), 1))) DESC) AS rnk

  FROM 

    "black_water_systems"."black_water_systems"

)

 

SELECT

  *

FROM

  max_tw

WHERE

  rnk = 1

 

This is the query and here is a row from the Athena output in the console:

 

2024-04-11 23:58:49

26200

36200

-0.3273

139.9605

7.7104

2.5324

6068.9761

7.7081

0.6482

7.2823

1393.8655

163.4366

1

 

This is what Tableau is deciding to do

Tableau doesn't seem to care about the casting in my custom SQL queryThis is just a snip of the first 5 columns for the same date from the same query in Tableau. Tableau is arbitrarily deciding to add 0's to the end or Cut off decimal places instead of just providing the output from Athena.

 

Why does this matter? Because later in Prep I have to STR these fields to get rid of some NULLS in a UNION to turn them into a blank cell and when I do that with a Calculated field like so - IFNULL(STR(ROUND([MOS_TMP],4)),'') Tableau was also deciding to add a huge bunch of digits to the end of the number even with the ROUND in the function. So, if the number had 10 digits after the decimal Tableau would either add 999997 or 000001 to the end of the rounded number. Therefore, I decided to fix it at the query, and it's still not working correctly in Tableau.

 

I cannot for the life of me figure out why either of these issues is happening. Any ideas?

2 respuestas
  1. 24 may 2024, 13:59

    Hi Ryan,

     

    Tableau usually reads the first X rows and then categorises the data type that way. Have you changed the value of the first N rows to something higher to see if it can capture the types?

     

    Hi Ryan, Tableau usually reads the first X rows and then categorises the data type that way. Have you changed the value of the first N rows to something higher to see if it can capture the types? 

    Thanks,

    Mavis

0/9000