Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to Substrait 0.43, add min. precision timestamp support #124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/substrait/textplan/PlanPrinterVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ std::any PlanPrinterVisitor::visitType(const ::substrait::proto::Type& type) {
case ::substrait::proto::Type::kMap:
case ::substrait::proto::Type::kUserDefined:
case ::substrait::proto::Type::kUserDefinedTypeReference:
case ::substrait::proto::Type::kPrecisionTimestamp:
case ::substrait::proto::Type::kPrecisionTimestampTz:
errorListener_->addError(
"Unsupported type requested: " + type.ShortDebugString());
return std::string("UNSUPPORTED_TYPE");
Expand Down Expand Up @@ -572,6 +574,8 @@ std::any PlanPrinterVisitor::visitLiteral(
case ::substrait::proto::Expression_Literal::kEmptyList:
case ::substrait::proto::Expression_Literal::kEmptyMap:
case ::substrait::proto::Expression_Literal::kUserDefined:
case ::substrait::proto::Expression_Literal::kPrecisionTimestamp:
case ::substrait::proto::Expression_Literal::kPrecisionTimestampTz:
errorListener_->addError(
"Literal of this type not yet supported: " +
literal.ShortDebugString());
Expand Down
5 changes: 5 additions & 0 deletions src/substrait/textplan/converter/BasePlanProtoVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ std::any BasePlanProtoVisitor::visitType(const ::substrait::proto::Type& type) {
case ::substrait::proto::Type::kUserDefined:
return visitTypeUserDefined(type.user_defined());
case ::substrait::proto::Type::kUserDefinedTypeReference:
case ::substrait::proto::Type::kPrecisionTimestamp:
case ::substrait::proto::Type::kPrecisionTimestampTz:
SUBSTRAIT_UNSUPPORTED(
"user_defined_type_reference was replaced by user_defined_type. "
"Please update your plan version.");
Expand Down Expand Up @@ -366,6 +368,9 @@ std::any BasePlanProtoVisitor::visitLiteral(
return visitTypeMap(literal.empty_map());
case ::substrait::proto::Expression_Literal::kUserDefined:
return visitUserDefined(literal.user_defined());
case ::substrait::proto::Expression_Literal::kPrecisionTimestamp:
case ::substrait::proto::Expression_Literal::kPrecisionTimestampTz:
return std::nullopt;
case ::substrait::proto::Expression_Literal::LITERAL_TYPE_NOT_SET:
break;
}
Expand Down
18 changes: 18 additions & 0 deletions src/substrait/textplan/parser/SubstraitPlanRelationVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
#include "substrait/textplan/StructuredSymbolData.h"
#include "substrait/textplan/SymbolTable.h"

// The visitor should try and be tolerant of older plans. This
// requires calling deprecated APIs.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma gcc diagnostic push
#pragma gcc diagnostic ignored "-Wdeprecated-declarations"

namespace io::substrait::textplan {

namespace {
Expand Down Expand Up @@ -147,6 +154,14 @@ void setNullable(::substrait::proto::Type* type) {
type->mutable_user_defined()->set_nullability(
::substrait::proto::Type_Nullability_NULLABILITY_NULLABLE);
break;
case ::substrait::proto::Type::kPrecisionTimestamp:
type->mutable_precision_timestamp()->set_nullability(
::substrait::proto::Type_Nullability_NULLABILITY_NULLABLE);
break;
case ::substrait::proto::Type::kPrecisionTimestampTz:
type->mutable_precision_timestamp_tz()->set_nullability(
::substrait::proto::Type_Nullability_NULLABILITY_NULLABLE);
break;
case ::substrait::proto::Type::kUserDefinedTypeReference:
case ::substrait::proto::Type::KIND_NOT_SET:
// We are guaranteed to have a valid type so no need to emit an error.
Expand Down Expand Up @@ -2166,3 +2181,6 @@ bool SubstraitPlanRelationVisitor::hasSubquery(
}

} // namespace io::substrait::textplan

#pragma clang diagnostic pop
#pragma gcc diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
#include "substrait/textplan/StructuredSymbolData.h"
#include "substrait/textplan/SymbolTable.h"

// The visitor should try and be tolerant of older plans. This
// requires calling deprecated APIs.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma gcc diagnostic push
#pragma gcc diagnostic ignored "-Wdeprecated-declarations"

namespace io::substrait::textplan {

namespace {
Expand Down Expand Up @@ -147,6 +154,14 @@ void setNullable(::substrait::proto::Type* type) {
type->mutable_user_defined()->set_nullability(
::substrait::proto::Type_Nullability_NULLABILITY_NULLABLE);
break;
case ::substrait::proto::Type::kPrecisionTimestamp:
type->mutable_precision_timestamp()->set_nullability(
::substrait::proto::Type_Nullability_NULLABILITY_NULLABLE);
break;
case ::substrait::proto::Type::kPrecisionTimestampTz:
type->mutable_precision_timestamp_tz()->set_nullability(
::substrait::proto::Type_Nullability_NULLABILITY_NULLABLE);
break;
case ::substrait::proto::Type::kUserDefinedTypeReference:
case ::substrait::proto::Type::KIND_NOT_SET:
// We are guaranteed to have a valid type so no need to emit an error.
Expand Down Expand Up @@ -2278,3 +2293,6 @@ bool SubstraitPlanSubqueryRelationVisitor::isWithinSubquery(
}

} // namespace io::substrait::textplan

#pragma clang diagnostic pop
#pragma gcc diagnostic pop
10 changes: 10 additions & 0 deletions src/substrait/textplan/parser/SubstraitPlanTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#include "substrait/textplan/SymbolTable.h"
#include "substrait/type/Type.h"

// The visitor should try and be tolerant of older plans. This
// requires calling deprecated APIs.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma gcc diagnostic push
#pragma gcc diagnostic ignored "-Wdeprecated-declarations"

namespace io::substrait::textplan {

std::any SubstraitPlanTypeVisitor::visitLiteral_basic_type(
Expand Down Expand Up @@ -202,3 +209,6 @@ bool SubstraitPlanTypeVisitor::insideStructLiteralWithExternalType(
}

} // namespace io::substrait::textplan

#pragma clang diagnostic pop
#pragma gcc diagnostic pop
Loading