Skip to content

Commit

Permalink
check float if scale > 0 in snowflake query result (getredash#3876)
Browse files Browse the repository at this point in the history
  • Loading branch information
wudi-ayuan authored and harveyrendell committed Nov 14, 2019
1 parent c86e04c commit d3d125a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion redash/query_runner/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def configuration_schema(cls):
def enabled(cls):
return enabled

@classmethod
def determine_type(cls, data_type, scale):
t = TYPES_MAP.get(data_type, None)
if t == TYPE_INTEGER and scale > 0:
return TYPE_FLOAT
return t

def run_query(self, query, user):
region = self.configuration.get('region')

Expand All @@ -84,7 +91,7 @@ def run_query(self, query, user):
cursor.execute(query)

columns = self.fetch_columns(
[(i[0], TYPES_MAP.get(i[1], None)) for i in cursor.description])
[(i[0], self.determine_type(i[1], i[5])) for i in cursor.description])
rows = [dict(zip((c['name'] for c in columns), row))
for row in cursor]

Expand Down

0 comments on commit d3d125a

Please sign in to comment.