EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB484353: Presto database instance shows the data type of a string column as VarChar (0) in the Warehouse Catalog


Community Admin

• Strategy


This article explains why the data type of a string column from a Presto displays the incorrect value, VarChar (0). This article also provides a workaround to avoid this behavior.

Description 


In the Warehouse Catalog, the data type of the string column from a Presto table displays as VarChar (0). The following can be seen via Developer. 
 

ka04W000001IwnqQAC_0EM2R000001HoYV.jpeg

Why is this happening?


If the table in Presto defines the column as VarChar (300) (e.g., 

create table testtable (col1 varchar (300)) ;
), then the data type in the Warehouse Catalog will correctly display VarChar (300). However, if the column is defined as a string data type (e.g.,
 create table testtable (col1 string) ;
), then the Warehouse Catalog will display VarChar (0). 

Workaround

  • In the Warehouse Catalog, go to Options. 
ka04W000001IwnqQAC_0EM2R000001HoYk.jpeg
  • Go to Catalog > Read Settings and click Settings.
ka04W000001IwnqQAC_0EM2R000001HoZ9.jpeg
  • Replace the column catalog SQL with the following string:
    
    SELECT table_schema NAME_SPACE, table_name TAB_NAME, column_name COL_NAME,  
    case when data_type like 'char(%' then 'char' when data_type like 'varchar(%' then 'varchar' when data_type like 'decimal(%' then 'decimal' else data_type end DATA_TYPE,  
    case when data_type = 'varchar' then '335' else split_part(replace(replace(substr(data_type, position('(' in data_type)), '(', ''), ')', ''), ',',1) end DATA_LEN,  
    case when data_type = 'varchar' then '335' else split_part(replace(replace(substr(data_type, position('(' in data_type)), '(', ''), ')', ''), ',',1) end DATA_PREC,  
    split_part(replace(replace(substr(data_type, position('(' in data_type)), '(', ''), ')', ''), ',',2) as DATA_SCALE  
    FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name in (#TABLE_LIST#) and TABLE_SCHEMA = '#Login_Name#' ORDER BY 1, 2, 3
    

     
ka04W000001IwnqQAC_0EM2R000001HoZJ.jpeg
  • Click OK, refresh the tables, and then read the table structure. The string column has the correct value set in the catalog column SQL:
ka04W000001IwnqQAC_0EM2R000001HoZO.jpeg

Comment

0 comments

Details

Knowledge Article

Published:

June 22, 2020

Last Updated:

June 22, 2020