mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 09:42:58 +00:00
* change dep Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * feat: adapt to arrow's interval array * chore: fix compile errors in datatypes crate * chore: fix api crate compiler errors * chore: fix compiler errors in common-grpc * chore: fix common-datasource errors * chore: fix deprecated code in common-datasource * fix promql and physical plan related Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * wip: upgrading network deps Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * block on updating `sqlparser` * upgrade sqlparser Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * adapt new df's trait requirements Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: fix compiler errors in mito2 * chore: fix common-function crate errors * chore: fix catalog errors * change import path Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: fix some errors in query crate * chore: fix some errors in query crate * aggr expr and some other tiny fixes Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: fix expr related errors in query crate * chore: fix query serializer and admin command * chore: fix grpc services * feat: axum serve * chore: fix http server * remove handle_error handler * refactor timeout layer * serve axum * chore: fix flow aggr functions * chore: fix flow * feat: fix errors in meta-srv * boxed() * use TokioIo * feat!: Remove script crate and python feature (#5321) * feat: exclude script crate * chore: simplify feature * feat: remove the script crate * chore: remove python feature and some comments * chore: fix warning * chore: fix servers tests compiler errors * feat: fix tests-integration errors * chore: fix unused * test: fix catalog test * chore: fix compiler errors for crates using common-meta testing feature is enabled when check with --workspace * test: use display for logical plan test * test: implement rewrite for ScanHintRule * fix: http server build panic * test: fix mito test * fix: sql parser type alias error * test: fix TestClient not listen * test: some flow tests * test(flow): more fix * fix: test_otlp_logs * test: fix promql test that using deprecated method fun() * fix: sql type replace supports Int8 ~ Int64, UInt8 ~ UInt64 * test: fix infer schema test case * test: fix tests related to plan display * chore: fix last flow test * test: fix function format related assertion * test: use larger port range for tests * fix: test_otlp_traces * fix: test_otlp_metrics * fix range query and dist plan Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix: flow handle distinct use deprecated field * fix: can't pass Join plan expressions to LogicalPlan::with_new_exprs * test: fix deserialize test * test: reduce split key case num * tests: lower case aggr func name * test: fix some sqlness tests * tests: more sqlness fix * tests: fixed sqlness test * commit non-bug changes Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix: make our udf correct * fix: implement empty methods of ContextProvider for DfContextProviderAdapter * test: update sqlness test result * chore: remove unused * fix: provide alias name for AggregateExprBuilder in range plan * test: update range query result * fix: implement missing ContextProvider methods for DfContextProviderAdapter * test: update timestamps, cte result * fix: supports empty projection in mito * test: update comment for cte test * fix: support projection for numbers * test: update test cases after projection fix * fix: fix range select first_value/last_value * fix: handle CAST and time index conflict * fix: handle order by correctly in range first_value/last_value * test: update sqlness result * test: update view test result * test: update decimal test wait for https://github.com/apache/datafusion/pull/14126 to fix this * feat: remove redundant physical optimization todo(ruihang): Check if we can remove this. * test: update sqlness test result * chore: range select default sort use nulls_first = false * test: update filter push down test result * test: comment deciaml test to avoid different panic message * test: update some distributed test result * test: update test for distributed count and filter push down * test: update subqueries test * fix: SessionState may overwrite our UDFs * chore: fix compiler errors after merging main * fix: fix elasticsearch and dashboard router panic * chore: fix common-functions tests * chore: update sqlness result * test: fix id keyword and update sqlness result * test: fix flow_null test * fix: enlarge thread size in debug mode to avoid overflow * chore: fix warnings in common-function * chore: fix warning in flow * chore: fix warnings in query crate * chore: remove unused warnings * chore: fix deprecated warnings for parquet * chore: fix deprecated warning in servers crate * style: fix clippy * test: enlarge mito cache tttl test ttl time * chore: fix typo * style: fmt toml * refactor: reimplement PartialOrd for RangeSelect * chore: remove script crate files introduced by merge * fix: return error if sql option is not kv * chore: do not use ..default::default() * chore: per review * chore: update error message in BuildAdminFunctionArgsSnafu Co-authored-by: jeremyhi <jiachun_feng@proton.me> * refactor: typed precision * update sqlness view case Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: flow per review * chore: add example in comment * chore: warn if parquet stats of timestamp is not INT64 * style: add a newline before derive to make the comment more clear * test: update sqlness result * fix: flow from substrait * chore: change update_range_context log to debug level * chore: move axum-extra axum-macros to workspace --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: luofucong <luofc@foxmail.com> Co-authored-by: discord9 <discord9@163.com> Co-authored-by: shuiyisong <xixing.sys@gmail.com> Co-authored-by: jeremyhi <jiachun_feng@proton.me>
221 lines
13 KiB
Plaintext
221 lines
13 KiB
Plaintext
--- date_add ---
|
|
SELECT date_add('2023-12-06 07:39:46.222'::TIMESTAMP_MS, INTERVAL '5 day');
|
|
|
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| date_add(arrow_cast(Utf8("2023-12-06 07:39:46.222"),Utf8("Timestamp(Millisecond, None)")),IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }")) |
|
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 2023-12-11T07:39:46.222 |
|
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_add('2023-12-06 07:39:46.222'::TIMESTAMP_MS, '5 day');
|
|
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
| date_add(arrow_cast(Utf8("2023-12-06 07:39:46.222"),Utf8("Timestamp(Millisecond, None)")),Utf8("5 day")) |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
| 2023-12-11T07:39:46.222 |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_add('2023-12-06'::DATE, INTERVAL '3 month 5 day');
|
|
|
|
+------------------------------------------------------------------------------------------------------------------+
|
|
| date_add(Utf8("2023-12-06"),IntervalMonthDayNano("IntervalMonthDayNano { months: 3, days: 5, nanoseconds: 0 }")) |
|
|
+------------------------------------------------------------------------------------------------------------------+
|
|
| 2024-03-11 |
|
|
+------------------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_add('2023-12-06'::DATE, '3 month 5 day');
|
|
|
|
+----------------------------------------------------+
|
|
| date_add(Utf8("2023-12-06"),Utf8("3 month 5 day")) |
|
|
+----------------------------------------------------+
|
|
| 2024-03-11 |
|
|
+----------------------------------------------------+
|
|
|
|
--- date_sub ---
|
|
SELECT date_sub('2023-12-06 07:39:46.222'::TIMESTAMP_MS, INTERVAL '5 day');
|
|
|
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| date_sub(arrow_cast(Utf8("2023-12-06 07:39:46.222"),Utf8("Timestamp(Millisecond, None)")),IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }")) |
|
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 2023-12-01T07:39:46.222 |
|
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_sub('2023-12-06 07:39:46.222'::TIMESTAMP_MS, '5 day');
|
|
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
| date_sub(arrow_cast(Utf8("2023-12-06 07:39:46.222"),Utf8("Timestamp(Millisecond, None)")),Utf8("5 day")) |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
| 2023-12-01T07:39:46.222 |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_sub('2023-12-06'::DATE, INTERVAL '3 month 5 day');
|
|
|
|
+------------------------------------------------------------------------------------------------------------------+
|
|
| date_sub(Utf8("2023-12-06"),IntervalMonthDayNano("IntervalMonthDayNano { months: 3, days: 5, nanoseconds: 0 }")) |
|
|
+------------------------------------------------------------------------------------------------------------------+
|
|
| 2023-09-01 |
|
|
+------------------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_sub('2023-12-06'::DATE, '3 month 5 day');
|
|
|
|
+----------------------------------------------------+
|
|
| date_sub(Utf8("2023-12-06"),Utf8("3 month 5 day")) |
|
|
+----------------------------------------------------+
|
|
| 2023-09-01 |
|
|
+----------------------------------------------------+
|
|
|
|
--- date_format ---
|
|
SELECT date_format('2023-12-06 07:39:46.222'::TIMESTAMP_MS, '%Y-%m-%d %H:%M:%S:%3f');
|
|
|
|
+-----------------------------------------------------------------------------------------------------------------------------+
|
|
| date_format(arrow_cast(Utf8("2023-12-06 07:39:46.222"),Utf8("Timestamp(Millisecond, None)")),Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+-----------------------------------------------------------------------------------------------------------------------------+
|
|
| 2023-12-06 07:39:46:222 |
|
|
+-----------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_format('2023-12-06 07:39:46.222'::TIMESTAMP_S, '%Y-%m-%d %H:%M:%S:%3f');
|
|
|
|
+------------------------------------------------------------------------------------------------------------------------+
|
|
| date_format(arrow_cast(Utf8("2023-12-06 07:39:46.222"),Utf8("Timestamp(Second, None)")),Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+------------------------------------------------------------------------------------------------------------------------+
|
|
| 2023-12-06 07:39:46:000 |
|
|
+------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
--- datetime not supported yet ---
|
|
SELECT date_format('2023-12-06 07:39:46.222'::DATETIME, '%Y-%m-%d %H:%M:%S:%3f');
|
|
|
|
Error: 1001(Unsupported), Failed to plan SQL: This feature is not implemented: Unsupported SQL type Datetime(None)
|
|
|
|
SELECT date_format('2023-12-06'::DATE, '%m-%d');
|
|
|
|
+-----------------------------------------------+
|
|
| date_format(Utf8("2023-12-06"),Utf8("%m-%d")) |
|
|
+-----------------------------------------------+
|
|
| 12-06 |
|
|
+-----------------------------------------------+
|
|
|
|
--- test date functions with table rows ---
|
|
CREATE TABLE dates(d DATE, ts timestamp time index);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO dates VALUES ('1992-01-01'::DATE, 1);
|
|
|
|
Affected Rows: 1
|
|
|
|
INSERT INTO dates VALUES ('1993-12-30'::DATE, 2);
|
|
|
|
Affected Rows: 1
|
|
|
|
INSERT INTO dates VALUES ('2023-12-06'::DATE, 3);
|
|
|
|
Affected Rows: 1
|
|
|
|
--- date_add ---
|
|
SELECT date_add(d, INTERVAL '1 year 2 month 3 day') from dates;
|
|
|
|
+--------------------------------------------------------------------------------------------------------+
|
|
| date_add(dates.d,IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 3, nanoseconds: 0 }")) |
|
|
+--------------------------------------------------------------------------------------------------------+
|
|
| 1993-03-04 |
|
|
| 1995-03-03 |
|
|
| 2025-02-09 |
|
|
+--------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_add(d, '1 year 2 month 3 day') from dates;
|
|
|
|
+------------------------------------------------+
|
|
| date_add(dates.d,Utf8("1 year 2 month 3 day")) |
|
|
+------------------------------------------------+
|
|
| 1993-03-04 |
|
|
| 1995-03-03 |
|
|
| 2025-02-09 |
|
|
+------------------------------------------------+
|
|
|
|
SELECT date_add(ts, INTERVAL '1 year 2 month 3 day') from dates;
|
|
|
|
+---------------------------------------------------------------------------------------------------------+
|
|
| date_add(dates.ts,IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 3, nanoseconds: 0 }")) |
|
|
+---------------------------------------------------------------------------------------------------------+
|
|
| 1971-03-04T00:00:00.001 |
|
|
| 1971-03-04T00:00:00.002 |
|
|
| 1971-03-04T00:00:00.003 |
|
|
+---------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_add(ts, '1 year 2 month 3 day') from dates;
|
|
|
|
+-------------------------------------------------+
|
|
| date_add(dates.ts,Utf8("1 year 2 month 3 day")) |
|
|
+-------------------------------------------------+
|
|
| 1971-03-04T00:00:00.001 |
|
|
| 1971-03-04T00:00:00.002 |
|
|
| 1971-03-04T00:00:00.003 |
|
|
+-------------------------------------------------+
|
|
|
|
--- date_sub ---
|
|
SELECT date_sub(d, INTERVAL '1 year 2 month 3 day') from dates;
|
|
|
|
+--------------------------------------------------------------------------------------------------------+
|
|
| date_sub(dates.d,IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 3, nanoseconds: 0 }")) |
|
|
+--------------------------------------------------------------------------------------------------------+
|
|
| 1990-10-29 |
|
|
| 1992-10-27 |
|
|
| 2022-10-03 |
|
|
+--------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_sub(d, '1 year 2 month 3 day') from dates;
|
|
|
|
+------------------------------------------------+
|
|
| date_sub(dates.d,Utf8("1 year 2 month 3 day")) |
|
|
+------------------------------------------------+
|
|
| 1990-10-29 |
|
|
| 1992-10-27 |
|
|
| 2022-10-03 |
|
|
+------------------------------------------------+
|
|
|
|
SELECT date_sub(ts, INTERVAL '1 year 2 month 3 day') from dates;
|
|
|
|
+---------------------------------------------------------------------------------------------------------+
|
|
| date_sub(dates.ts,IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 3, nanoseconds: 0 }")) |
|
|
+---------------------------------------------------------------------------------------------------------+
|
|
| 1968-10-29T00:00:00.001 |
|
|
| 1968-10-29T00:00:00.002 |
|
|
| 1968-10-29T00:00:00.003 |
|
|
+---------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT date_sub(ts, '1 year 2 month 3 day') from dates;
|
|
|
|
+-------------------------------------------------+
|
|
| date_sub(dates.ts,Utf8("1 year 2 month 3 day")) |
|
|
+-------------------------------------------------+
|
|
| 1968-10-29T00:00:00.001 |
|
|
| 1968-10-29T00:00:00.002 |
|
|
| 1968-10-29T00:00:00.003 |
|
|
+-------------------------------------------------+
|
|
|
|
--- date_format ---
|
|
SELECT date_format(d, '%Y-%m-%d %H:%M:%S:%3f') from dates;
|
|
|
|
+----------------------------------------------------+
|
|
| date_format(dates.d,Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+----------------------------------------------------+
|
|
| 1992-01-01 00:00:00:000 |
|
|
| 1993-12-30 00:00:00:000 |
|
|
| 2023-12-06 00:00:00:000 |
|
|
+----------------------------------------------------+
|
|
|
|
SELECT date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from dates;
|
|
|
|
+-----------------------------------------------------+
|
|
| date_format(dates.ts,Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+-----------------------------------------------------+
|
|
| 1970-01-01 00:00:00:001 |
|
|
| 1970-01-01 00:00:00:002 |
|
|
| 1970-01-01 00:00:00:003 |
|
|
+-----------------------------------------------------+
|
|
|
|
DROP TABLE dates;
|
|
|
|
Affected Rows: 0
|
|
|