Adapt superset's time aggregation queries to iotdb syntax
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:
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.