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

Add plan validator for timestamp with timezone check for prestissimo #23200

Merged

Conversation

feilong-liu
Copy link
Contributor

@feilong-liu feilong-liu commented Jul 12, 2024

Description

Detail in discussion of #23191

Add a plan checker for Prestissimo, so that queries which have timestamp with timezone type will fail.

Motivation and Context

Fix facebookincubator/velox#10338

Impact

Only affect Prestissimo

Test Plan

existing unit tests and
end to end test with queries in the issue:

presto:sf1> select cast(x as timestamp with time zone), count(1) from unnest(array['2024-04-10 07:00 America/Los_Angeles', '2024-04-10 10:00 America/New_York']) as t(x) group by 1;
Query 20240712_205745_00033_5bggp failed: Timestamp with Timezone type is not supported in Prestissimo
java.lang.IllegalStateException: Timestamp with Timezone type is not supported in Prestissimo
	at com.google.common.base.Preconditions.checkState(Preconditions.java:507)
	at com.facebook.presto.sql.planner.sanity.CheckNoTimestampWithNoTimezoneType$Visitor.visitPlan(CheckNoTimestampWithNoTimezoneType.java:63)
	at com.facebook.presto.sql.planner.sanity.CheckNoTimestampWithNoTimezoneType$Visitor.visitPlan(CheckNoTimestampWithNoTimezoneType.java:50)
	at com.facebook.presto.spi.plan.PlanVisitor.visitOutput(PlanVisitor.java:25)
	at com.facebook.presto.spi.plan.OutputNode.accept(OutputNode.java:98)
	at com.facebook.presto.sql.planner.sanity.CheckNoTimestampWithNoTimezoneType.validate(CheckNoTimestampWithNoTimezoneType.java:47)
	at com.facebook.presto.sql.planner.sanity.PlanChecker.lambda$validateFinalPlan$0(PlanChecker.java:81)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:407)
	at com.facebook.presto.sql.planner.sanity.PlanChecker.validateFinalPlan(PlanChecker.java:81)
	at com.facebook.presto.sql.Optimizer.validateAndOptimizePlan(Optimizer.java:131)
	at com.facebook.presto.execution.SqlQueryExecution.lambda$createLogicalPlanAndOptimize$3(SqlQueryExecution.java:557)
	at com.facebook.presto.common.RuntimeStats.profileNanos(RuntimeStats.java:136)
	at com.facebook.presto.execution.SqlQueryExecution.createLogicalPlanAndOptimize(SqlQueryExecution.java:555)
	at com.facebook.presto.execution.SqlQueryExecution.start(SqlQueryExecution.java:463)
	at com.facebook.presto.$gen.Presto_null__testversion____20240712_205726_4.run(Unknown Source)
	at com.facebook.presto.execution.SqlQueryManager.createQuery(SqlQueryManager.java:319)
	at com.facebook.presto.dispatcher.LocalDispatchQuery.lambda$startExecution$8(LocalDispatchQuery.java:213)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Add a plan checker so that queries having timestamp with timezone type will fail in prestissimo :pr:`23200`

@aditi-pandit
Copy link
Contributor

@feilong-liu : Thanks for this code. MIght be great to put this behind a co-ordinator config so that we can enable/disable in our clusters easily as the underlying issue is getting fixed in Velox.

@feilong-liu feilong-liu requested a review from a team as a code owner July 12, 2024 22:33
@feilong-liu
Copy link
Contributor Author

@feilong-liu : Thanks for this code. MIght be great to put this behind a co-ordinator config so that we can enable/disable in our clusters easily as the underlying issue is getting fixed in Velox.

Added one more feature config for it

@feilong-liu feilong-liu force-pushed the timestamp_timezone_validate branch 2 times, most recently from b418e6e to 9855049 Compare July 13, 2024 00:11
Copy link
Contributor

@amitkdutta amitkdutta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my end.
@aditi-pandit @tdcmeehan See if you have any comments.

@@ -1211,22 +1211,22 @@ public void testArithmetic()
@Test
public void testTimestampWithTimeZone()
{
assertQuery("SELECT from_unixtime(orderkey, '+01:00'), from_unixtime(orderkey, '-05:00'), from_unixtime(orderkey, 'Europe/Moscow') FROM orders");
assertQuery("SELECT from_unixtime(orderkey, '+01:00'), count(1) FROM orders GROUP BY 1");
assertQueryFails("SELECT from_unixtime(orderkey, '+01:00'), from_unixtime(orderkey, '-05:00'), from_unixtime(orderkey, 'Europe/Moscow') FROM orders", ".*Timestamp with Timezone type is not supported in Prestissimo.*");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for validating the behavior in e2e tests.

@@ -2601,6 +2602,19 @@ public boolean isNativeExecutionEnabled()
return this.nativeExecutionEnabled;
}

@Config("disable-timestamp-with-timezone-for-native-execution")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gggrace14 @kgpai @kagamiori For testing the timestamp comparison features, we will need to turn this on in deployment configs.

@feilong-liu feilong-liu merged commit b693975 into prestodb:master Jul 13, 2024
59 checks passed
@feilong-liu feilong-liu deleted the timestamp_timezone_validate branch July 13, 2024 05:51
@aditi-pandit
Copy link
Contributor

+1. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comparisons for values of logical types are not handled correctly throughout the library
4 participants