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

Make PRIMARY a non-reserved keyword #22115

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

ClarenceThreepwood
Copy link
Contributor

@ClarenceThreepwood ClarenceThreepwood commented Mar 7, 2024

Follow up to #20384 and #22092

@ClarenceThreepwood ClarenceThreepwood marked this pull request as ready for review March 7, 2024 20:10
@ClarenceThreepwood ClarenceThreepwood requested a review from a team as a code owner March 7, 2024 20:10
Copy link

github-actions bot commented Mar 7, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff 4b453a5...0a86f27.

Notify File(s)
@aditi-pandit presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@elharo presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@kaikalur presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@rschlussel presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@steveburnett presto-docs/src/main/sphinx/language/reserved.rst

rschlussel
rschlussel previously approved these changes Mar 7, 2024
Copy link
Contributor

@rschlussel rschlussel left a comment

Choose a reason for hiding this comment

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

can you add tests for a select query

@rschlussel rschlussel dismissed their stale review March 7, 2024 20:16

needs more tests

kaikalur
kaikalur previously approved these changes Mar 7, 2024
steveburnett
steveburnett previously approved these changes Mar 7, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull branch, new local build, looks good.

tdcmeehan
tdcmeehan previously approved these changes Mar 7, 2024
actualResult = computeActual("SHOW CREATE TABLE " + tableName);
assertEquals(getOnlyElement(actualResult.getOnlyColumnAsSet()), expectedcreateTableWithOneConstraint);
// Since PRIMARY is a non-reserved keyword, it gets parsed and then fails at column resolution
assertQueryFails("SELECT PRIMARY FROM " + tableName, ".*cannot be resolved.*");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rschlussel - is this what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. I just meant to ensure that primary will work as a column name in a regular query.

actualResult = computeActual("SHOW CREATE TABLE " + tableName);
assertEquals(getOnlyElement(actualResult.getOnlyColumnAsSet()), expectedcreateTableWithOneConstraint);
// Since PRIMARY is a non-reserved keyword, it gets parsed and then fails at column resolution
assertQueryFails("SELECT PRIMARY FROM " + tableName, ".*cannot be resolved.*");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. I just meant to ensure that primary will work as a column name in a regular query.

@tdcmeehan tdcmeehan merged commit 75ebaf1 into prestodb:master Mar 8, 2024
57 checks passed
@ClarenceThreepwood ClarenceThreepwood deleted the primary branch March 8, 2024 17:56
@stevechuck
Copy link
Contributor

@ClarenceThreepwood one of our tests started to fail after your changes have landed, could you check if it's related?

testCreateTableWithConstraints (com.facebook.presto.sql.parser.TestSqlParser)
com.facebook.presto.sql.parser.ParsingException: line 1:83: mismatched input ')'. Expecting: '('
	at com.facebook.presto.sql.parser.ErrorHandler.syntaxError(ErrorHandler.java:109)
	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
	at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:327)
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
	at com.facebook.presto.sql.parser.SqlBaseParser.columnAliases(SqlBaseParser.java:7715)
	at com.facebook.presto.sql.parser.SqlBaseParser.unnamedConstraintSpecification(SqlBaseParser.java:14385)
	at com.facebook.presto.sql.parser.SqlBaseParser.constraintSpecification(SqlBaseParser.java:14269)
	at com.facebook.presto.sql.parser.SqlBaseParser.tableElement(SqlBaseParser.java:4626)
	at com.facebook.presto.sql.parser.SqlBaseParser.statement(SqlBaseParser.java:2382)
	at com.facebook.presto.sql.parser.SqlBaseParser.singleStatement(SqlBaseParser.java:268)
	at com.facebook.presto.sql.parser.SqlParser.invokeParser(SqlParser.java:173)
	at com.facebook.presto.sql.parser.SqlParser.createStatement(SqlParser.java:108)
	at com.facebook.presto.sql.parser.SqlParser.createStatement(SqlParser.java:103)
	at com.facebook.presto.sql.parser.TestSqlParser.assertStatement(TestSqlParser.java:3028)
	at com.facebook.presto.sql.parser.TestSqlParser.testCreateTableWithConstraints(TestSqlParser.java:2999)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
	at org.testng.TestRunner.privateRun(TestRunner.java:756)
	at org.testng.TestRunner.run(TestRunner.java:610)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
	at org.testng.SuiteRunner.run(SuiteRunner.java:289)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
	at org.testng.TestNG.runSuites(TestNG.java:1133)
	at org.testng.TestNG.run(TestNG.java:1104)
	at com.facebook.buck.testrunner.TestNGRunner.run(TestNGRunner.java:98)
	at com.facebook.buck.testrunner.BaseRunner.runAndExit(BaseRunner.java:313)
	at com.facebook.buck.testrunner.TestNGMain.main(TestNGMain.java:48)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.facebook.buck.jvm.java.runner.FileClassPathRunner.main(FileClassPathRunner.java:93)
Caused by: org.antlr.v4.runtime.InputMismatchException
	at com.facebook.presto.sql.parser.SqlParser$2.recoverInline(SqlParser.java:147)
	at org.antlr.v4.runtime.Parser.match(Parser.java:206)
	at com.facebook.presto.sql.parser.SqlBaseParser.columnAliases(SqlBaseParser.java:7690)
	... 40 more

@ClarenceThreepwood
Copy link
Contributor Author

@stevechuck - Looks like this newly added test case was run with a stale build. Please upgrade and see if it reproduces

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.

6 participants