diff --git a/cpp-ch/local-engine/Builder/SerializedPlanBuilder.cpp b/cpp-ch/local-engine/Builder/SerializedPlanBuilder.cpp index f90bd121760d..3d80670087c4 100644 --- a/cpp-ch/local-engine/Builder/SerializedPlanBuilder.cpp +++ b/cpp-ch/local-engine/Builder/SerializedPlanBuilder.cpp @@ -107,7 +107,7 @@ SchemaPtr SerializedSchemaBuilder::build() else if (type == "Timestamp") { auto * t = type_struct->mutable_types()->Add(); - t->mutable_timestamp()->set_nullability( + t->mutable_timestamp_tz()->set_nullability( this->nullability_map[name] ? substrait::Type_Nullability_NULLABILITY_NULLABLE : substrait::Type_Nullability_NULLABILITY_REQUIRED); } @@ -256,7 +256,7 @@ std::shared_ptr SerializedPlanBuilder::buildType(const DB::Data const auto * ch_type_datetime64 = checkAndGetDataType(ch_type_without_nullable.get()); if (ch_type_datetime64->getScale() != 6) throw Exception(ErrorCodes::UNKNOWN_TYPE, "Spark doesn't support converting from {}", ch_type->getName()); - res->mutable_timestamp()->set_nullability(type_nullability); + res->mutable_timestamp_tz()->set_nullability(type_nullability); } else if (which.isDate32()) res->mutable_date()->set_nullability(type_nullability); @@ -365,7 +365,7 @@ substrait::Expression * literalTimestamp(int64_t value) { substrait::Expression * rel = new substrait::Expression(); auto * literal = rel->mutable_literal(); - literal->set_timestamp(value); + literal->set_timestamp_tz(value); return rel; } diff --git a/cpp-ch/local-engine/Parser/ExpressionParser.cpp b/cpp-ch/local-engine/Parser/ExpressionParser.cpp index 39aabcf2d2b8..12392a9dfe13 100644 --- a/cpp-ch/local-engine/Parser/ExpressionParser.cpp +++ b/cpp-ch/local-engine/Parser/ExpressionParser.cpp @@ -112,9 +112,9 @@ std::pair LiteralParser::parse(const substrait::Expr field = literal.date(); break; } - case substrait::Expression_Literal::kTimestamp: { + case substrait::Expression_Literal::kTimestampTz: { type = std::make_shared(6); - field = DecimalField(literal.timestamp(), 6); + field = DecimalField(literal.timestamp_tz(), 6); break; } case substrait::Expression_Literal::kDecimal: { diff --git a/cpp-ch/local-engine/Parser/TypeParser.cpp b/cpp-ch/local-engine/Parser/TypeParser.cpp index 49e76fdb31e8..bdb8c52e9c21 100644 --- a/cpp-ch/local-engine/Parser/TypeParser.cpp +++ b/cpp-ch/local-engine/Parser/TypeParser.cpp @@ -153,10 +153,10 @@ DB::DataTypePtr TypeParser::parseType(const substrait::Type & substrait_type, st ch_type = std::make_shared(); ch_type = tryWrapNullable(substrait_type.fp64().nullability(), ch_type); } - else if (substrait_type.has_timestamp()) + else if (substrait_type.has_timestamp_tz()) { ch_type = std::make_shared(6); - ch_type = tryWrapNullable(substrait_type.timestamp().nullability(), ch_type); + ch_type = tryWrapNullable(substrait_type.timestamp_tz().nullability(), ch_type); } else if (substrait_type.has_date()) { diff --git a/cpp/velox/substrait/SubstraitParser.cc b/cpp/velox/substrait/SubstraitParser.cc index ed4ad36c689c..2bc1dd71c301 100644 --- a/cpp/velox/substrait/SubstraitParser.cc +++ b/cpp/velox/substrait/SubstraitParser.cc @@ -76,7 +76,7 @@ TypePtr SubstraitParser::parseType(const ::substrait::Type& substraitType, bool return UNKNOWN(); case ::substrait::Type::KindCase::kDate: return DATE(); - case ::substrait::Type::KindCase::kTimestamp: + case ::substrait::Type::KindCase::kTimestampTz: return TIMESTAMP(); case ::substrait::Type::KindCase::kDecimal: { auto precision = substraitType.decimal().precision(); @@ -368,7 +368,7 @@ bool SubstraitParser::getLiteralValue(const ::substrait::Expression::Literal& li template <> Timestamp SubstraitParser::getLiteralValue(const ::substrait::Expression::Literal& literal) { - return Timestamp::fromMicros(literal.timestamp()); + return Timestamp::fromMicros(literal.timestamp_tz()); } template <> diff --git a/cpp/velox/substrait/SubstraitToVeloxExpr.cc b/cpp/velox/substrait/SubstraitToVeloxExpr.cc index fdee942eaa57..25e78de7095b 100755 --- a/cpp/velox/substrait/SubstraitToVeloxExpr.cc +++ b/cpp/velox/substrait/SubstraitToVeloxExpr.cc @@ -131,7 +131,7 @@ TypePtr getScalarType(const ::substrait::Expression::Literal& literal) { } case ::substrait::Expression_Literal::LiteralTypeCase::kDate: return DATE(); - case ::substrait::Expression_Literal::LiteralTypeCase::kTimestamp: + case ::substrait::Expression_Literal::LiteralTypeCase::kTimestampTz: return TIMESTAMP(); case ::substrait::Expression_Literal::LiteralTypeCase::kString: return VARCHAR(); diff --git a/cpp/velox/substrait/VeloxToSubstraitExpr.cc b/cpp/velox/substrait/VeloxToSubstraitExpr.cc index f17fda06a2cf..66a2b4ff80f3 100644 --- a/cpp/velox/substrait/VeloxToSubstraitExpr.cc +++ b/cpp/velox/substrait/VeloxToSubstraitExpr.cc @@ -136,7 +136,7 @@ const ::substrait::Expression_Literal& toSubstraitNotNullLiteral( case velox::TypeKind::TIMESTAMP: { auto vTimeStamp = variantValue.value(); auto micros = vTimeStamp.getSeconds() * 1000000 + vTimeStamp.getNanos() / 1000; - literalExpr->set_timestamp(micros); + literalExpr->set_timestamp_tz(micros); break; } case velox::TypeKind::VARCHAR: { @@ -250,7 +250,7 @@ const ::substrait::Expression_Literal& toSubstraitNotNullLiteral(&arena); auto micros = value.getSeconds() * 1000000 + value.getNanos() / 1000; - literalExpr->set_timestamp(micros); + literalExpr->set_timestamp_tz(micros); literalExpr->set_nullable(false); return *literalExpr; } diff --git a/cpp/velox/substrait/VeloxToSubstraitType.cc b/cpp/velox/substrait/VeloxToSubstraitType.cc index b08fe83db6a1..b6bcf3bcc978 100644 --- a/cpp/velox/substrait/VeloxToSubstraitType.cc +++ b/cpp/velox/substrait/VeloxToSubstraitType.cc @@ -88,9 +88,9 @@ const ::substrait::Type& VeloxToSubstraitTypeConvertor::toSubstraitType( break; } case velox::TypeKind::TIMESTAMP: { - auto substraitTimestamp = google::protobuf::Arena::CreateMessage<::substrait::Type_Timestamp>(&arena); - substraitTimestamp->set_nullability(::substrait::Type_Nullability_NULLABILITY_NULLABLE); - substraitType->set_allocated_timestamp(substraitTimestamp); + auto substraitTimestampTZ = google::protobuf::Arena::CreateMessage<::substrait::Type_TimestampTZ>(&arena); + substraitTimestampTZ->set_nullability(::substrait::Type_Nullability_NULLABILITY_NULLABLE); + substraitType->set_allocated_timestamp_tz(substraitTimestampTZ); break; } case velox::TypeKind::ARRAY: { diff --git a/gluten-substrait/src/main/java/org/apache/gluten/substrait/expression/TimestampLiteralNode.java b/gluten-substrait/src/main/java/org/apache/gluten/substrait/expression/TimestampLiteralNode.java index ec253edbc4a3..15e7254e179d 100644 --- a/gluten-substrait/src/main/java/org/apache/gluten/substrait/expression/TimestampLiteralNode.java +++ b/gluten-substrait/src/main/java/org/apache/gluten/substrait/expression/TimestampLiteralNode.java @@ -32,6 +32,6 @@ public TimestampLiteralNode(Long value, TypeNode typeNode) { @Override protected void updateLiteralBuilder(Builder literalBuilder, Long value) { - literalBuilder.setTimestamp(value); + literalBuilder.setTimestampTz(value); } } diff --git a/gluten-substrait/src/main/java/org/apache/gluten/substrait/type/TimestampTypeNode.java b/gluten-substrait/src/main/java/org/apache/gluten/substrait/type/TimestampTypeNode.java index f25b5e900eda..472df5da97fe 100644 --- a/gluten-substrait/src/main/java/org/apache/gluten/substrait/type/TimestampTypeNode.java +++ b/gluten-substrait/src/main/java/org/apache/gluten/substrait/type/TimestampTypeNode.java @@ -26,7 +26,7 @@ public TimestampTypeNode(Boolean nullable) { @Override public Type toProtobuf() { - Type.Timestamp.Builder timestampBuilder = Type.Timestamp.newBuilder(); + Type.TimestampTZ.Builder timestampBuilder = Type.TimestampTZ.newBuilder(); if (nullable) { timestampBuilder.setNullability(Type.Nullability.NULLABILITY_NULLABLE); } else { @@ -34,7 +34,7 @@ public Type toProtobuf() { } Type.Builder builder = Type.newBuilder(); - builder.setTimestamp(timestampBuilder.build()); + builder.setTimestampTz(timestampBuilder.build()); return builder.build(); } } diff --git a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ConverterUtils.scala b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ConverterUtils.scala index 1e217eb5647e..6db1f188d8bc 100644 --- a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ConverterUtils.scala +++ b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ConverterUtils.scala @@ -160,8 +160,8 @@ object ConverterUtils extends Logging { (StringType, isNullable(substraitType.getString.getNullability)) case Type.KindCase.BINARY => (BinaryType, isNullable(substraitType.getBinary.getNullability)) - case Type.KindCase.TIMESTAMP => - (TimestampType, isNullable(substraitType.getTimestamp.getNullability)) + case Type.KindCase.TIMESTAMP_TZ => + (TimestampType, isNullable(substraitType.getTimestampTz.getNullability)) case Type.KindCase.DATE => (DateType, isNullable(substraitType.getDate.getNullability)) case Type.KindCase.DECIMAL =>