-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
date_trunc function when connect to hive #7270
Comments
Same here. I've checked the source code in incubator-superset/superset/db_engine_specs.py, from what I'm seeing, the reason this error happened is because they're using PrestoEngineSpec as HiveEngineSpec, as the code below: class HiveEngineSpec(PrestoEngineSpec):
"""Reuses PrestoEngineSpec functionality.""" and hive doesn't support 'date_trunc' method. class HiveEngineSpec(BaseEngineSpec):
"""Reuses PrestoEngineSpec functionality."""
engine = 'hive'
max_column_name_length = 767
time_grain_functions = {
None: '{col}',
'PT1S': "from_unixtime(unix_timestamp({col}), 'yyyy-MM-dd HH:mm:ss')",
'PT1M': "from_unixtime(unix_timestamp({col}), 'yyyy-MM-dd HH:mm:00')",
'PT1H': "from_unixtime(unix_timestamp({col}), 'yyyy-MM-dd HH:00:00')",
'P1D': "from_unixtime(unix_timestamp({col}), 'yyyy-MM-dd 00:00:00')",
'P1W': "date_format(date_sub(nianxian, CAST(7-from_unixtime(unix_timestamp(nianxian),'u') as int)), 'yyyy-MM-dd 00:00:00')",
'P1M': "from_unixtime(unix_timestamp({col}), 'yyyy-MM-01 00:00:00')",
'P0.25Y': "date_format(add_months(trunc(nianxian, 'MM'), -(month(nianxian)-1)%3), 'yyyy-MM-dd 00:00:00')",
'P1Y': "from_unixtime(unix_timestamp({col}), 'yyyy-01-01 00:00:00')",
'P1W/1970-01-03T00:00:00Z': "date_format(date_add(nianxian, INT(6-from_unixtime(unix_timestamp(nianxian), 'u'))), 'yyyy-MM-dd 00:00:00')",
'1969-12-28T00:00:00Z/P1W': "date_format(date_add(nianxian, -INT(from_unixtime(unix_timestamp(nianxian), 'u'))), 'yyyy-MM-dd 00:00:00')"
} this should do the work. |
@jeepxiaozi |
sorry about the code part, I've edited a little bit so that u can see it clearly |
@jeepxiaozi thank you for the fix! Could you create a pull request to the apache project please? :) |
+1 for this one ;) |
Remember you can override time grain functions in |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
Make sure these boxes are checked before submitting your issue - thank you!
Superset version
0.28.1
Expected results
Actual results
Steps to reproduce
When I create time series bar chart, Superset uses 'date_trunc' function in hiveql group by clause and it raise exception.
The text was updated successfully, but these errors were encountered: