Gradsta opened a new issue, #21669:
URL: https://github.com/apache/superset/issues/21669

   The predictive analytics feature available in some charts does not appear to 
work with datasets created using the Trino connector.
   
   #### How to reproduce the bug
   
   You will need a Superset instance configured with a Trino database that in 
turn connects to a Postgres database. The same Postgres database should also be 
set up as a database within Superset.
   
   ##### Postgres
   
   1. Create a dataset with two columns, both of type VARCHAR—I used the upload 
a CSV feature in Superset to do this.
   ```
   date,value
   2022-09-30,12363
   2022-09-29,87263
   2022-09-28,82342
   2022-09-27,23412
   2022-09-26,54365
   ``` 
   2. In SQL Editor, execute the following query (note: my schema is named 
`upload` and my table is named `predictive_analytics` in this example) against 
the **Postgres** database configured in Superset.
   ```sql
   SELECT
     CAST(date AS TIMESTAMP) AS date,
     CAST(value AS INTEGER) AS value
   FROM upload.predictive_analytics
   ```
   3. Create a chart, enabling forecast (see expected results section)
   
   ##### Trino
   
   1.  In SQL Editor, execute the following query (note: my Trino catalog is 
named `superset`, my schema is named `upload`, and my table is named 
`predictive_analytics` in this example) against the **Trino** database 
configured in Superset.
   ```sql
   SELECT
     CAST(date AS TIMESTAMP) AS date,
     CAST(value AS INTEGER) AS value
   FROM superset.upload.predictive_analytics
   ```
   
   2. Create a chart, enabling forecast (see expected results section)
   
   ### Expected results
   
   I would expect both charts to be able to render the predictive analytics 
results.
   
   ### Actual results
   
   In the chart created using the Postgres connector, predictive analytics 
works just fine.
   <img width="1680" alt="Screen Shot 2022-09-30 at 6 10 14 PM" 
src="https://user-images.githubusercontent.com/41174775/193368551-03502da4-b871-4137-8d79-7750913f326e.png";>
   
   In the chart created using the Trino connector, the following error is 
presented: `Can only use .dt accessor with datetimelike values`.
   
   <img width="1680" alt="Screen Shot 2022-09-30 at 6 09 59 PM" 
src="https://user-images.githubusercontent.com/41174775/193369031-263215a6-dea4-47b5-85d7-17261147fbf6.png";>
   
   ### Environment
   
   (please complete the following information):
   
   - browser type and version: Chrome 105.0.5195.102
   - superset version: `2.0.0`
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   
   ### Additional context
   
   Applicable stacktrace:
   ```
   2022-09-30 23:09:41,442:ERROR:superset.views.base:Can only use .dt accessor 
with datetimelike values
   Traceback (most recent call last):
     File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in 
full_dispatch_request
       rv = self.dispatch_request()
     File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in 
dispatch_request
       return 
self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
     File 
"/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py",
 line 89, in wraps
       return f(self, *args, **kwargs)
     File "/app/superset/views/base_api.py", line 113, in wraps
       raise ex
     File "/app/superset/views/base_api.py", line 110, in wraps
       duration, response = time_function(f, self, *args, **kwargs)
     File "/app/superset/utils/core.py", line 1507, in time_function
       response = func(*args, **kwargs)
     File "/app/superset/utils/log.py", line 245, in wrapper
       value = f(*args, **kwargs)
     File "/app/superset/charts/data/api.py", line 244, in data
       return self._get_data_response(
     File "/app/superset/charts/data/api.py", line 390, in _get_data_response
       result = command.run(force_cached=force_cached)
     File "/app/superset/charts/data/commands/get_data_command.py", line 43, in 
run
       payload = self._query_context.get_payload(
     File "/app/superset/common/query_context.py", line 96, in get_payload
       return self._processor.get_payload(cache_query_context, force_cached)
     File "/app/superset/common/query_context_processor.py", line 386, in 
get_payload
       query_results = [
     File "/app/superset/common/query_context_processor.py", line 387, in 
<listcomp>
       get_query_results(
     File "/app/superset/common/query_actions.py", line 200, in 
get_query_results
       return result_func(query_context, query_obj, force_cached)
     File "/app/superset/common/query_actions.py", line 162, in _get_results
       payload = _get_full(query_context, query_obj, force_cached)
     File "/app/superset/common/query_actions.py", line 104, in _get_full
       payload = query_context.get_df_payload(query_obj, 
force_cached=force_cached)
     File "/app/superset/common/query_context.py", line 115, in get_df_payload
       return self._processor.get_df_payload(query_obj, force_cached)
     File "/app/superset/common/query_context_processor.py", line 126, in 
get_df_payload
       query_result = self.get_query_result(query_obj)
     File "/app/superset/common/query_context_processor.py", line 208, in 
get_query_result
       df = query_object.exec_post_processing(df)
     File "/app/superset/common/query_object.py", line 446, in 
exec_post_processing
       df = getattr(pandas_postprocessing, operation)(df, **options)
     File "/app/superset/utils/pandas_postprocessing/prophet.py", line 138, in 
prophet
       fit_df = _prophet_fit_and_predict(
     File "/app/superset/utils/pandas_postprocessing/prophet.py", line 68, in 
_prophet_fit_and_predict
       if df["ds"].dt.tz:
     File "/usr/local/lib/python3.8/site-packages/pandas/core/generic.py", line 
5487, in __getattr__
       return object.__getattribute__(self, name)
     File "/usr/local/lib/python3.8/site-packages/pandas/core/accessor.py", 
line 181, in __get__
       accessor_obj = self._accessor(obj)
     File 
"/usr/local/lib/python3.8/site-packages/pandas/core/indexes/accessors.py", line 
506, in __new__
       raise AttributeError("Can only use .dt accessor with datetimelike 
values")
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to