diff --git a/fe/be-java-extensions/max-compute-scanner/src/main/java/org/apache/doris/maxcompute/MaxComputeColumnValue.java b/fe/be-java-extensions/max-compute-scanner/src/main/java/org/apache/doris/maxcompute/MaxComputeColumnValue.java index 68e66bba1a50bd..ea92f062d09fb9 100644 --- a/fe/be-java-extensions/max-compute-scanner/src/main/java/org/apache/doris/maxcompute/MaxComputeColumnValue.java +++ b/fe/be-java-extensions/max-compute-scanner/src/main/java/org/apache/doris/maxcompute/MaxComputeColumnValue.java @@ -30,6 +30,7 @@ import org.apache.arrow.vector.IntVector; import org.apache.arrow.vector.SmallIntVector; import org.apache.arrow.vector.TimeStampMilliTZVector; +import org.apache.arrow.vector.TimeStampNanoTZVector; import org.apache.arrow.vector.TimeStampNanoVector; import org.apache.arrow.vector.TinyIntVector; import org.apache.arrow.vector.ValueVector; @@ -242,15 +243,17 @@ public LocalDateTime getDateTime() { LocalDateTime result; ArrowType.Timestamp timestampType = ( ArrowType.Timestamp) column.getField().getFieldType().getType(); - if (timestampType.getUnit() == org.apache.arrow.vector.types.TimeUnit.MILLISECOND) { + if (timestampType.getUnit() == org.apache.arrow.vector.types.TimeUnit.MILLISECOND) { //DATETIME result = convertToLocalDateTime((TimeStampMilliTZVector) column, idx); - } else { + } else if (timestampType.getTimezone() == null) { // TIMESTAMP_NTZ NullableTimeStampNanoHolder valueHoder = new NullableTimeStampNanoHolder(); ((TimeStampNanoVector) column).get(idx, valueHoder); long timestampNanos = valueHoder.value; result = LocalDateTime.ofEpochSecond(timestampNanos / 1_000_000_000, (int) (timestampNanos % 1_000_000_000), java.time.ZoneOffset.UTC); + } else { // TIMESTAMP + result = convertToLocalDateTime((TimeStampNanoTZVector) column, idx); } /* @@ -339,4 +342,9 @@ public LocalDateTime convertToLocalDateTime(TimeStampMilliTZVector milliTZVector return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestampMillis), timeZone); } + public LocalDateTime convertToLocalDateTime(TimeStampNanoTZVector nanoTZVector, int index) { + long timestampNano = nanoTZVector.get(index); + return Instant.ofEpochSecond(timestampNano / 1_000_000_000, timestampNano % 1_000_000_000) + .atZone(timeZone).toLocalDateTime(); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalCatalog.java index 27e4976aedd85e..1c8979ee1db5fc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalCatalog.java @@ -76,6 +76,8 @@ public class MaxComputeExternalCatalog extends ExternalCatalog { private int readTimeout; private int retryTimes; + public boolean dateTimePredicatePushDown; + private static final Map REGION_ZONE_MAP; private static final List REQUIRED_PROPERTIES = ImmutableList.of( MCProperties.PROJECT, @@ -201,7 +203,9 @@ protected void initLocalObjectsImpl() { accessKey = credential.getAccessKey(); secretKey = credential.getSecretKey(); - + dateTimePredicatePushDown = Boolean.parseBoolean( + props.getOrDefault(MCProperties.DATETIME_PREDICATE_PUSH_DOWN, + MCProperties.DEFAULT_DATETIME_PREDICATE_PUSH_DOWN)); Account account = new AliyunAccount(accessKey, secretKey); this.odps = new Odps(account); @@ -338,6 +342,10 @@ public int getReadTimeout() { return readTimeout; } + public boolean getDateTimePredicatePushDown() { + return dateTimePredicatePushDown; + } + public ZoneId getProjectDateTimeZone() { makeSureInitialized(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java index 7f626655442b09..1136fb079f3bcd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeExternalTable.java @@ -269,6 +269,7 @@ private Type mcTypeToDorisType(TypeInfo typeInfo) { case DATETIME: { return ScalarType.createDatetimeV2Type(3); } + case TIMESTAMP: case TIMESTAMP_NTZ: { return ScalarType.createDatetimeV2Type(6); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java index e4bb8b5e9dcc53..9235c237134126 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java @@ -88,6 +88,8 @@ import java.util.stream.Collectors; public class MaxComputeScanNode extends FileQueryScanNode { + static final DateTimeFormatter dateTime3Formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + static final DateTimeFormatter dateTime6Formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS"); private final MaxComputeExternalTable table; private Predicate filterPredicate; @@ -492,16 +494,40 @@ private String convertLiteralToOdpsValues(OdpsType odpsType, Expr expr) throws A return " \"" + dateLiteral.getStringValue(dstType) + "\" "; } case DATETIME: { - DateLiteral dateLiteral = (DateLiteral) literalExpr; - ScalarType dstType = ScalarType.createDatetimeV2Type(3); + MaxComputeExternalCatalog mcCatalog = (MaxComputeExternalCatalog) table.getCatalog(); + if (mcCatalog.getDateTimePredicatePushDown()) { + DateLiteral dateLiteral = (DateLiteral) literalExpr; + ScalarType dstType = ScalarType.createDatetimeV2Type(3); - return " \"" + convertDateTimezone(dateLiteral.getStringValue(dstType), - ((MaxComputeExternalCatalog) table.getCatalog()).getProjectDateTimeZone()) + "\" "; + return " \"" + convertDateTimezone(dateLiteral.getStringValue(dstType), dateTime3Formatter, + ZoneId.of("UTC")) + "\" "; + } + break; + } + /** + * Disable the predicate pushdown to the odps API because the timestamp precision of odps is 9 and the + * mapping precision of Doris is 6. If we insert `2023-02-02 00:00:00.123456789` into odps, doris reads + * it as `2023-02-02 00:00:00.123456`. Since "789" is missing, we cannot push it down correctly. + */ + case TIMESTAMP: { + MaxComputeExternalCatalog mcCatalog = (MaxComputeExternalCatalog) table.getCatalog(); + if (mcCatalog.getDateTimePredicatePushDown()) { + DateLiteral dateLiteral = (DateLiteral) literalExpr; + ScalarType dstType = ScalarType.createDatetimeV2Type(6); + + return " \"" + convertDateTimezone(dateLiteral.getStringValue(dstType), dateTime6Formatter, + ZoneId.of("UTC")) + "\" "; + } + break; } case TIMESTAMP_NTZ: { - DateLiteral dateLiteral = (DateLiteral) literalExpr; - ScalarType dstType = ScalarType.createDatetimeV2Type(6); - return " \"" + dateLiteral.getStringValue(dstType) + "\" "; + MaxComputeExternalCatalog mcCatalog = (MaxComputeExternalCatalog) table.getCatalog(); + if (mcCatalog.getDateTimePredicatePushDown()) { + DateLiteral dateLiteral = (DateLiteral) literalExpr; + ScalarType dstType = ScalarType.createDatetimeV2Type(6); + return " \"" + dateLiteral.getStringValue(dstType) + "\" "; + } + break; } default: { break; @@ -511,12 +537,11 @@ private String convertLiteralToOdpsValues(OdpsType odpsType, Expr expr) throws A } - public static String convertDateTimezone(String dateTimeStr, ZoneId toZone) { + public static String convertDateTimezone(String dateTimeStr, DateTimeFormatter formatter, ZoneId toZone) { if (DateUtils.getTimeZone().equals(toZone)) { return dateTimeStr; } - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); LocalDateTime localDateTime = LocalDateTime.parse(dateTimeStr, formatter); ZonedDateTime sourceZonedDateTime = localDateTime.atZone(DateUtils.getTimeZone()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/constants/MCProperties.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/constants/MCProperties.java index 3957ffc91bb4b4..8282134c5a19b9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/constants/MCProperties.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/constants/MCProperties.java @@ -71,6 +71,10 @@ public class MCProperties extends BaseProperties { public static final String SPLIT_CROSS_PARTITION = "mc.split_cross_partition"; public static final String DEFAULT_SPLIT_CROSS_PARTITION = "true"; + public static final String DATETIME_PREDICATE_PUSH_DOWN = + "mc.datetime_predicate_push_down"; + public static final String DEFAULT_DATETIME_PREDICATE_PUSH_DOWN = "true"; + public static CloudCredential getCredential(Map props) { return getCloudCredential(props, ACCESS_KEY, SECRET_KEY, SESSION_TOKEN); } diff --git a/regression-test/data/external_table_p2/maxcompute/test_max_compute_timestamp.out b/regression-test/data/external_table_p2/maxcompute/test_max_compute_timestamp.out new file mode 100644 index 00000000000000..125148aabc6aaf --- /dev/null +++ b/regression-test/data/external_table_p2/maxcompute/test_max_compute_timestamp.out @@ -0,0 +1,271 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !1_1 -- +2023-02-02T00:00 + +-- !1_2 -- + +-- !1_3 -- +2023-02-02T00:00 + +-- !1_4 -- +2023-02-02T00:00 + +-- !1_5 -- +2023-02-02T00:00 + +-- !1_6 -- + +-- !1_7 -- + +-- !2_1 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_2 -- + +-- !2_3 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_4 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_5 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_6 -- + +-- !2_7 -- + +-- !2_8 -- + +-- !2_9 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_10 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_11 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !2_12 -- + +-- !2_13 -- + +-- !3_1 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_2 -- + +-- !3_3 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_4 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_5 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_6 -- + +-- !3_7 -- + +-- !3_8 -- + +-- !3_9 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_10 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_11 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !3_12 -- + +-- !3_13 -- + +-- !4_1 -- +2023-02-01T16:00 + +-- !4_2 -- + +-- !4_3 -- +2023-02-01T16:00 + +-- !4_4 -- +2023-02-01T16:00 + +-- !4_5 -- +2023-02-01T16:00 + +-- !4_6 -- + +-- !4_7 -- + +-- !5_1 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_2 -- + +-- !5_3 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_4 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_5 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_6 -- + +-- !5_7 -- + +-- !5_8 -- + +-- !5_9 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_10 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_11 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !5_12 -- + +-- !5_13 -- + +-- !6_1 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_2 -- + +-- !6_3 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_4 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_5 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_6 -- + +-- !6_7 -- + +-- !6_8 -- + +-- !6_9 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_10 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_11 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !6_12 -- + +-- !6_13 -- + +-- !7_1 -- +2023-02-02T00:00 + +-- !7_2 -- + +-- !7_3 -- +2023-02-02T00:00 + +-- !7_4 -- +2023-02-02T00:00 + +-- !7_5 -- +2023-02-02T00:00 + +-- !7_6 -- + +-- !7_7 -- + +-- !8_1 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_2 -- + +-- !8_3 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_4 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_5 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_6 -- + +-- !8_7 -- + +-- !8_8 -- + +-- !8_9 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_10 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_11 -- +2023-02-02T00:00:00.123456 2023-02-02T00:00:00.123456 + +-- !8_12 -- + +-- !8_13 -- + +-- !9_1 -- +2023-02-01T16:00 + +-- !9_2 -- + +-- !9_3 -- +2023-02-01T16:00 + +-- !9_4 -- +2023-02-01T16:00 + +-- !9_5 -- +2023-02-01T16:00 + +-- !9_6 -- + +-- !9_7 -- + +-- !10_1 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_2 -- + +-- !10_3 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_4 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_5 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_6 -- + +-- !10_7 -- + +-- !10_8 -- + +-- !10_9 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_10 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_11 -- +2023-02-01T16:00:00.123456 2023-02-02T00:00:00.123456 + +-- !10_12 -- + +-- !10_13 -- + diff --git a/regression-test/suites/external_table_p2/maxcompute/test_max_compute_timestamp.groovy b/regression-test/suites/external_table_p2/maxcompute/test_max_compute_timestamp.groovy new file mode 100644 index 00000000000000..c7e8d7d035cf3b --- /dev/null +++ b/regression-test/suites/external_table_p2/maxcompute/test_max_compute_timestamp.groovy @@ -0,0 +1,216 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + +/* + + +drop table if EXISTS datetime_tb1; +CREATE TABLE datetime_tb1 (col1 datetime); +INSERT INTO TABLE datetime_tb1 VALUES(datetime "2023-02-02 00:00:00"); + +drop table if EXISTS timestamp_tb1; +CREATE TABLE timestamp_tb1 (col1 TIMESTAMP,col2 TIMESTAMP_NTZ); +INSERT INTO TABLE timestamp_tb1 VALUES(timestamp "2023-02-02 00:00:00.123456789", timestamp_ntz "2023-02-02 00:00:00.123456789"); + +drop table if EXISTS timestamp_tb2; +CREATE TABLE timestamp_tb2 (col1 TIMESTAMP,col2 TIMESTAMP_NTZ); +INSERT INTO TABLE timestamp_tb2 VALUES(timestamp "2023-02-02 00:00:00.123456", timestamp_ntz "2023-02-02 00:00:00.123456" ); +*/ + +suite("test_max_compute_timestamp", "p2,external,maxcompute,external_remote,external_remote_maxcompute") { + + + String enabled = context.config.otherConfigs.get("enableMaxComputeTest") + if (enabled != null && enabled.equalsIgnoreCase("true")) { + String ak = context.config.otherConfigs.get("ak") + String sk = context.config.otherConfigs.get("sk"); + String mc_db = "mc_datalake" + String mc_catalog_name = "test_max_compute_timestamp" + + sql """drop catalog if exists ${mc_catalog_name};""" + sql """ + create catalog if not exists ${mc_catalog_name} properties ( + "type" = "max_compute", + "mc.default.project" = "${mc_db}", + "mc.access_key" = "${ak}", + "mc.secret_key" = "${sk}", + "mc.endpoint" = "http://service.cn-beijing-vpc.maxcompute.aliyun-inc.com/api", + "mc.datetime_predicate_push_down" = "false" + ); + """ + sql """ switch ${mc_catalog_name} """ + sql """ use ${mc_db}""" + + sql """ set time_zone = "Asia/Shanghai" """ + qt_1_1 """ select * from datetime_tb1;""" + qt_1_2 """ select * from datetime_tb1 where col1 > "2023-02-02 00:00:00.000";""" + qt_1_3 """ select * from datetime_tb1 where col1 >= "2023-02-02 00:00:00.000";""" + qt_1_4 """ select * from datetime_tb1 where col1 = "2023-02-02 00:00:00.000";""" + qt_1_5 """ select * from datetime_tb1 where col1 <= "2023-02-02 00:00:00.000";""" + qt_1_6 """ select * from datetime_tb1 where col1 < "2023-02-02 00:00:00.000";""" + qt_1_7 """ select * from datetime_tb1 where col1 != "2023-02-02 00:00:00.000";""" + + + qt_2_1 """select * from timestamp_tb1;""" + qt_2_2 """select * from timestamp_tb1 where col1 > "2023-02-02 00:00:00.123456";""" + qt_2_3 """select * from timestamp_tb1 where col1 >= "2023-02-02 00:00:00.123456";""" + qt_2_4 """select * from timestamp_tb1 where col1 = "2023-02-02 00:00:00.123456";""" + qt_2_5 """select * from timestamp_tb1 where col1 <= "2023-02-02 00:00:00.123456";""" + qt_2_6 """select * from timestamp_tb1 where col1 < "2023-02-02 00:00:00.123456";""" + qt_2_7 """select * from timestamp_tb1 where col1 != "2023-02-02 00:00:00.123456"; """ + + qt_2_8 """ select * from timestamp_tb1 where col2 > "2023-02-02 00:00:00.123456"; """ + qt_2_9 """ select * from timestamp_tb1 where col2 >= "2023-02-02 00:00:00.123456"; """ + qt_2_10 """ select * from timestamp_tb1 where col2 = "2023-02-02 00:00:00.123456"; """ + qt_2_11 """ select * from timestamp_tb1 where col2 <= "2023-02-02 00:00:00.123456"; """ + qt_2_12 """ select * from timestamp_tb1 where col2 < "2023-02-02 00:00:00.123456"; """ + qt_2_13 """ select * from timestamp_tb1 where col2 != "2023-02-02 00:00:00.123456"; """ + + + + qt_3_1 """ select * from timestamp_tb2;""" + qt_3_2 """ select * from timestamp_tb2 where col1 > "2023-02-02 00:00:00.123456";""" + qt_3_3 """ select * from timestamp_tb2 where col1 >= "2023-02-02 00:00:00.123456";""" + qt_3_4 """ select * from timestamp_tb2 where col1 = "2023-02-02 00:00:00.123456";""" + qt_3_5 """ select * from timestamp_tb2 where col1 <= "2023-02-02 00:00:00.123456";""" + qt_3_6 """ select * from timestamp_tb2 where col1 < "2023-02-02 00:00:00.123456";""" + qt_3_7 """ select * from timestamp_tb2 where col1 != "2023-02-02 00:00:00.123456";""" + qt_3_8 """ select * from timestamp_tb2 where col2 > "2023-02-02 00:00:00.123456";""" + qt_3_9 """ select * from timestamp_tb2 where col2 >= "2023-02-02 00:00:00.123456";""" + qt_3_10 """ select * from timestamp_tb2 where col2 = "2023-02-02 00:00:00.123456";""" + qt_3_11 """ select * from timestamp_tb2 where col2 <= "2023-02-02 00:00:00.123456";""" + qt_3_12 """ select * from timestamp_tb2 where col2 < "2023-02-02 00:00:00.123456";""" + qt_3_13 """ select * from timestamp_tb2 where col2 != "2023-02-02 00:00:00.123456";""" + + + sql """ set time_zone = "UTC" """ + + qt_4_1 """ select * from datetime_tb1;""" + qt_4_2 """ select * from datetime_tb1 where col1 > "2023-02-01 16:00:00.000";""" + qt_4_3 """ select * from datetime_tb1 where col1 >= "2023-02-01 16:00:00.000";""" + qt_4_4 """ select * from datetime_tb1 where col1 = "2023-02-01 16:00:00.000";""" + qt_4_5 """ select * from datetime_tb1 where col1 <= "2023-02-01 16:00:00.000";""" + qt_4_6 """ select * from datetime_tb1 where col1 < "2023-02-01 16:00:00.000";""" + qt_4_7 """ select * from datetime_tb1 where col1 != "2023-02-01 16:00:00.000";""" + + + qt_5_1 """select * from timestamp_tb1;""" + qt_5_2 """select * from timestamp_tb1 where col1 > "2023-02-01 16:00:00.123456";""" + qt_5_3 """select * from timestamp_tb1 where col1 >= "2023-02-01 16:00:00.123456";""" + qt_5_4 """select * from timestamp_tb1 where col1 = "2023-02-01 16:00:00.123456";""" + qt_5_5 """select * from timestamp_tb1 where col1 <= "2023-02-01 16:00:00.123456";""" + qt_5_6 """select * from timestamp_tb1 where col1 < "2023-02-01 16:00:00.123456";""" + qt_5_7 """select * from timestamp_tb1 where col1 != "2023-02-01 16:00:00.123456"; """ + + qt_5_8 """ select * from timestamp_tb1 where col2 > "2023-02-02 00:00:00.123456"; """ + qt_5_9 """ select * from timestamp_tb1 where col2 >= "2023-02-02 00:00:00.123456"; """ + qt_5_10 """ select * from timestamp_tb1 where col2 = "2023-02-02 00:00:00.123456"; """ + qt_5_11 """ select * from timestamp_tb1 where col2 <= "2023-02-02 00:00:00.123456"; """ + qt_5_12 """ select * from timestamp_tb1 where col2 < "2023-02-02 00:00:00.123456"; """ + qt_5_13 """ select * from timestamp_tb1 where col2 != "2023-02-02 00:00:00.123456"; """ + + + + + + qt_6_1 """ select * from timestamp_tb2;""" + qt_6_2 """ select * from timestamp_tb2 where col1 > "2023-02-01 16:00:00.123456";""" + qt_6_3 """ select * from timestamp_tb2 where col1 >= "2023-02-01 16:00:00.123456";""" + qt_6_4 """ select * from timestamp_tb2 where col1 = "2023-02-01 16:00:00.123456";""" + qt_6_5 """ select * from timestamp_tb2 where col1 <= "2023-02-01 16:00:00.123456";""" + qt_6_6 """ select * from timestamp_tb2 where col1 < "2023-02-01 16:00:00.123456";""" + qt_6_7 """ select * from timestamp_tb2 where col1 != "2023-02-01 16:00:00.123456";""" + + qt_6_8 """ select * from timestamp_tb1 where col2 > "2023-02-02 00:00:00.123456"; """ + qt_6_9 """ select * from timestamp_tb1 where col2 >= "2023-02-02 00:00:00.123456"; """ + qt_6_10 """ select * from timestamp_tb1 where col2 = "2023-02-02 00:00:00.123456"; """ + qt_6_11 """ select * from timestamp_tb1 where col2 <= "2023-02-02 00:00:00.123456"; """ + qt_6_12 """ select * from timestamp_tb1 where col2 < "2023-02-02 00:00:00.123456"; """ + qt_6_13 """ select * from timestamp_tb1 where col2 != "2023-02-02 00:00:00.123456"; """ + + + + sql """drop catalog if exists ${mc_catalog_name}_2;""" + sql """ + create catalog if not exists ${mc_catalog_name}_2 properties ( + "type" = "max_compute", + "mc.default.project" = "${mc_db}", + "mc.access_key" = "${ak}", + "mc.secret_key" = "${sk}", + "mc.endpoint" = "http://service.cn-beijing-vpc.maxcompute.aliyun-inc.com/api", + "mc.datetime_predicate_push_down" = "true" + ); + """ + sql """ switch ${mc_catalog_name}_2 """ + sql """ use ${mc_db}""" + + + sql """ set time_zone = "Asia/Shanghai" """ + qt_7_1 """ select * from datetime_tb1;""" + qt_7_2 """ select * from datetime_tb1 where col1 > "2023-02-02 00:00:00.000";""" + qt_7_3 """ select * from datetime_tb1 where col1 >= "2023-02-02 00:00:00.000";""" + qt_7_4 """ select * from datetime_tb1 where col1 = "2023-02-02 00:00:00.000";""" + qt_7_5 """ select * from datetime_tb1 where col1 <= "2023-02-02 00:00:00.000";""" + qt_7_6 """ select * from datetime_tb1 where col1 < "2023-02-02 00:00:00.000";""" + qt_7_7 """ select * from datetime_tb1 where col1 != "2023-02-02 00:00:00.000";""" + + + qt_8_1 """ select * from timestamp_tb2;""" + qt_8_2 """ select * from timestamp_tb2 where col1 > "2023-02-02 00:00:00.123456";""" + qt_8_3 """ select * from timestamp_tb2 where col1 >= "2023-02-02 00:00:00.123456";""" + qt_8_4 """ select * from timestamp_tb2 where col1 = "2023-02-02 00:00:00.123456";""" + qt_8_5 """ select * from timestamp_tb2 where col1 <= "2023-02-02 00:00:00.123456";""" + qt_8_6 """ select * from timestamp_tb2 where col1 < "2023-02-02 00:00:00.123456";""" + qt_8_7 """ select * from timestamp_tb2 where col1 != "2023-02-02 00:00:00.123456";""" + qt_8_8 """ select * from timestamp_tb2 where col2 > "2023-02-02 00:00:00.123456";""" + qt_8_9 """ select * from timestamp_tb2 where col2 >= "2023-02-02 00:00:00.123456";""" + qt_8_10 """ select * from timestamp_tb2 where col2 = "2023-02-02 00:00:00.123456";""" + qt_8_11 """ select * from timestamp_tb2 where col2 <= "2023-02-02 00:00:00.123456";""" + qt_8_12 """ select * from timestamp_tb2 where col2 < "2023-02-02 00:00:00.123456";""" + qt_8_13 """ select * from timestamp_tb2 where col2 != "2023-02-02 00:00:00.123456";""" + + sql """ set time_zone = "UTC" """ + + qt_9_1 """ select * from datetime_tb1;""" + qt_9_2 """ select * from datetime_tb1 where col1 > "2023-02-01 16:00:00.000";""" + qt_9_3 """ select * from datetime_tb1 where col1 >= "2023-02-01 16:00:00.000";""" + qt_9_4 """ select * from datetime_tb1 where col1 = "2023-02-01 16:00:00.000";""" + qt_9_5 """ select * from datetime_tb1 where col1 <= "2023-02-01 16:00:00.000";""" + qt_9_6 """ select * from datetime_tb1 where col1 < "2023-02-01 16:00:00.000";""" + qt_9_7 """ select * from datetime_tb1 where col1 != "2023-02-01 16:00:00.000";""" + + + + qt_10_1 """ select * from timestamp_tb2;""" + qt_10_2 """ select * from timestamp_tb2 where col1 > "2023-02-01 16:00:00.123456";""" + qt_10_3 """ select * from timestamp_tb2 where col1 >= "2023-02-01 16:00:00.123456";""" + qt_10_4 """ select * from timestamp_tb2 where col1 = "2023-02-01 16:00:00.123456";""" + qt_10_5 """ select * from timestamp_tb2 where col1 <= "2023-02-01 16:00:00.123456";""" + qt_10_6 """ select * from timestamp_tb2 where col1 < "2023-02-01 16:00:00.123456";""" + qt_10_7 """ select * from timestamp_tb2 where col1 != "2023-02-01 16:00:00.123456";""" + + qt_10_8 """ select * from timestamp_tb1 where col2 > "2023-02-02 00:00:00.123456"; """ + qt_10_9 """ select * from timestamp_tb1 where col2 >= "2023-02-02 00:00:00.123456"; """ + qt_10_10 """ select * from timestamp_tb1 where col2 = "2023-02-02 00:00:00.123456"; """ + qt_10_11 """ select * from timestamp_tb1 where col2 <= "2023-02-02 00:00:00.123456"; """ + qt_10_12 """ select * from timestamp_tb1 where col2 < "2023-02-02 00:00:00.123456"; """ + qt_10_13 """ select * from timestamp_tb1 where col2 != "2023-02-02 00:00:00.123456"; """ + + } +} \ No newline at end of file