diff --git a/core/trino-main/src/test/java/io/trino/connector/TestingTableFunctions.java b/core/trino-main/src/test/java/io/trino/connector/TestingTableFunctions.java index 4febbe36409a..f9a60c5dcf0b 100644 --- a/core/trino-main/src/test/java/io/trino/connector/TestingTableFunctions.java +++ b/core/trino-main/src/test/java/io/trino/connector/TestingTableFunctions.java @@ -253,6 +253,40 @@ public TableFunctionAnalysis analyze(ConnectorSession session, ConnectorTransact } } + public static class ThreeTableArgumentsFunction + extends AbstractConnectorTableFunction + { + public ThreeTableArgumentsFunction() + { + super( + SCHEMA_NAME, + "three_table_arguments_function", + ImmutableList.of( + TableArgumentSpecification.builder() + .name("INPUT1") + .build(), + TableArgumentSpecification.builder() + .name("INPUT2") + .build(), + TableArgumentSpecification.builder() + .name("INPUT3") + .build()), + GENERIC_TABLE); + } + + @Override + public TableFunctionAnalysis analyze(ConnectorSession session, ConnectorTransactionHandle transaction, Map arguments) + { + return TableFunctionAnalysis.builder() + .handle(HANDLE) + .returnedType(new Descriptor(ImmutableList.of(new Descriptor.Field(COLUMN_NAME, Optional.of(BOOLEAN))))) + .requiredColumns("INPUT1", ImmutableList.of(0)) + .requiredColumns("INPUT2", ImmutableList.of(0)) + .requiredColumns("INPUT3", ImmutableList.of(0)) + .build(); + } + } + public static class OnlyPassThroughFunction extends AbstractConnectorTableFunction { diff --git a/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java b/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java index fd072332e8a5..0820f1dec73b 100644 --- a/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java +++ b/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java @@ -32,6 +32,7 @@ import io.trino.connector.TestingTableFunctions.RequiredColumnsFunction; import io.trino.connector.TestingTableFunctions.TableArgumentFunction; import io.trino.connector.TestingTableFunctions.TableArgumentRowSemanticsFunction; +import io.trino.connector.TestingTableFunctions.ThreeTableArgumentsFunction; import io.trino.connector.TestingTableFunctions.TwoScalarArgumentsFunction; import io.trino.connector.TestingTableFunctions.TwoTableArgumentsFunction; import io.trino.execution.DynamicFilterConfig; @@ -6462,6 +6463,14 @@ public void testCopartitionColumns() """) .hasErrorCode(TYPE_MISMATCH) .hasMessage("line 4:18: Partitioning columns in copartitioned tables have incompatible types"); + + analyze(""" + SELECT * FROM TABLE(system.three_table_arguments_function( + input1 => TABLE(SELECT 1) t1(a) PARTITION BY (a), + input2 => TABLE(SELECT 2) t2(b) PARTITION BY (b), + input3 => TABLE(SELECT 3) + COPARTITION (t1, t2))) + """); } @Test @@ -7040,6 +7049,7 @@ public ConnectorTransactionHandle getConnectorTransaction(TransactionId transact new TableArgumentRowSemanticsFunction(), new DescriptorArgumentFunction(), new TwoTableArgumentsFunction(), + new ThreeTableArgumentsFunction(), new OnlyPassThroughFunction(), new MonomorphicStaticReturnTypeFunction(), new PolymorphicStaticReturnTypeFunction(), diff --git a/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4 b/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4 index 4898866069cc..f071ecf826c2 100644 --- a/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4 +++ b/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4 @@ -833,7 +833,7 @@ nonReserved // IMPORTANT: this rule must only contain tokens. Nested rules are not supported. See SqlParser.exitNonReserved : ABSENT | ADD | ADMIN | AFTER | ALL | ANALYZE | ANY | ARRAY | ASC | AT | AUTHORIZATION | BERNOULLI | BOTH - | CALL | CASCADE | CATALOGS | COLUMN | COLUMNS | COMMENT | COMMIT | COMMITTED | CONDITIONAL | COPARTITION | COUNT | CURRENT + | CALL | CASCADE | CATALOGS | COLUMN | COLUMNS | COMMENT | COMMIT | COMMITTED | CONDITIONAL | COUNT | CURRENT | DATA | DATE | DAY | DEFAULT | DEFINE | DEFINER | DENY | DESC | DESCRIPTOR | DISTRIBUTED | DOUBLE | EMPTY | ENCODING | ERROR | EXCLUDING | EXPLAIN | FETCH | FILTER | FINAL | FIRST | FOLLOWING | FORMAT | FUNCTIONS diff --git a/docs/src/main/sphinx/language/reserved.rst b/docs/src/main/sphinx/language/reserved.rst index 0bb6c42c6c80..b4547a0c104e 100644 --- a/docs/src/main/sphinx/language/reserved.rst +++ b/docs/src/main/sphinx/language/reserved.rst @@ -17,6 +17,7 @@ Keyword SQL:2016 SQL-92 ``CASE`` reserved reserved ``CAST`` reserved reserved ``CONSTRAINT`` reserved reserved +``COPARTITION`` ``CREATE`` reserved reserved ``CROSS`` reserved reserved ``CUBE`` reserved