linxt20 opened a new pull request, #10261:
URL: https://github.com/apache/iotdb/pull/10261

   Description:
   This pull request modifies the behavior of superset when handling time 
columns in the x-axis or aggregate columns. Currently, superset defaults to 
using time-based aggregation segments for aggregate functions, employing the 
syntax "GROUP BY TRUNC(interval, 'Time')". However, iotdb utilizes a different 
syntax for time-based aggregation segments, which is "GROUP BY ([startTime, 
endTime), interval)". This creates a conflict in syntax between superset and 
iotdb. This PR addresses this issue by making the necessary modifications to 
iotdb, enabling compatibility with time-based aggregation queries in superset.
   
   Effect:
   
![image](https://github.com/apache/iotdb/assets/78125067/46c54c1a-ee5f-4e5d-aa05-519aab932347)
   
   Implementation:
   The implementation involves adding a flag in the group_by_clause of 
sqlalchemy/IOTDBSQLcompiler.py to indicate the time-based aggregation segment 
operation as "GROUP BY ([startTime, endTime), 1s)". Additionally, it converts 
the interval in superset's syntax to iotdb's syntax. Furthermore, in the 
execute function of dbapi/Cursor.py, the SQL statement is intercepted before it 
is sent to the iotdb server. The code then retrieves the maximum timestamp of 
the base table using the execution function, with the aggregate functions 
changed to MAX_VALUE. Similarly, it retrieves the minimum timestamp by 
switching the functions to MIN_VALUE. The startTime and endTime placeholders in 
the flagged statement are then replaced with the respective timestamps using 
regex matching. Finally, the modified GROUP BY statement is appended to the 
query SQL statement.


-- 
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]

Reply via email to