-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds links to removed DML statements Removes ExprRow in favor of ExprRowValue
- Loading branch information
1 parent
4035919
commit a8e9c1c
Showing
14 changed files
with
321 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
partiql-ast/src/main/java/org/partiql/ast/expr/ExprRow.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
partiql-parser/src/test/kotlin/org/partiql/parser/internal/ArgumentsProviderBase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at: | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package org.partiql.parser.internal | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import java.util.stream.Stream | ||
|
||
/** | ||
* Reduces some of the boilerplate associated with the style of parameterized testing frequently | ||
* utilized in this package. | ||
* | ||
* Since JUnit5 requires `@JvmStatic` on its `@MethodSource` argument factory methods, this requires all | ||
* of the argument lists to reside in the companion object of a test class. This can be annoying since it | ||
* forces the test to be separated from its tests cases. | ||
* | ||
* Classes that derive from this class can be defined near the `@ParameterizedTest` functions instead. | ||
*/ | ||
abstract class ArgumentsProviderBase : ArgumentsProvider { | ||
|
||
abstract fun getParameters(): List<Any> | ||
|
||
@Throws(Exception::class) | ||
override fun provideArguments(extensionContext: ExtensionContext): Stream<out Arguments>? { | ||
return getParameters().map { Arguments.of(it) }.stream() | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
partiql-parser/src/test/kotlin/org/partiql/parser/internal/DeleteStatementTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.partiql.parser.internal | ||
|
||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
|
||
class DeleteStatementTests { | ||
|
||
@ParameterizedTest | ||
@ArgumentsSource(SuccessTestCases::class) | ||
fun success(tc: PTestDef) { | ||
tc.assert() | ||
} | ||
|
||
@ParameterizedTest | ||
@ArgumentsSource(FailureTestCases::class) | ||
fun failure(tc: PTestDef) { | ||
tc.assert() | ||
} | ||
|
||
object SuccessTestCases : ArgumentsProviderBase() { | ||
override fun getParameters(): List<ParserTestCaseSimple> { | ||
val m = mapOf( | ||
"Simplest test" to "DELETE FROM tbl", | ||
"Simplest deletion with condition" to "DELETE FROM tbl WHERE a = 2", | ||
"Namespaced table name" to "DELETE FROM \"CaT1\".schema1.\"TBL_1\"", | ||
"Namespaced table name with condition" to "DELETE FROM \"CaT1\".schema1.\"TBL_1\" WHERE y < x", | ||
).entries.map { ParserTestCaseSimple(it.key, it.value, isValid = true) } | ||
return m | ||
} | ||
} | ||
|
||
object FailureTestCases : ArgumentsProviderBase() { | ||
override fun getParameters(): List<ParserTestCaseSimple> { | ||
val m = mapOf( | ||
"Lack of table name" to "DELETE FROM WHERE a = 2", | ||
"Lack of condition" to "DELETE FROM tbl WHERE", | ||
).entries.map { ParserTestCaseSimple(it.key, it.value, isValid = false) } | ||
return m | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
partiql-parser/src/test/kotlin/org/partiql/parser/internal/InsertStatementTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.partiql.parser.internal | ||
|
||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
|
||
class InsertStatementTests { | ||
|
||
@ParameterizedTest | ||
@ArgumentsSource(SuccessTestCases::class) | ||
fun success(tc: PTestDef) { | ||
tc.assert() | ||
} | ||
|
||
@ParameterizedTest | ||
@ArgumentsSource(FailureTestCases::class) | ||
fun failure(tc: PTestDef) { | ||
tc.assert() | ||
} | ||
|
||
object SuccessTestCases : ArgumentsProviderBase() { | ||
override fun getParameters(): List<ParserTestCaseSimple> { | ||
val m = mapOf( | ||
"Simplest insert of a row" to "INSERT INTO tbl VALUES (1, 2, 3)", | ||
"Column definitions" to "INSERT INTO tbl (a, b, c) VALUES (1, 2, 3)", | ||
"Multiple rows" to "INSERT INTO tbl VALUES (1, 2, 3), (4, 5, 6), (7, 8, 8)", | ||
"Multiple non-row values" to "INSERT INTO tbl VALUES 1, 2, 3", | ||
"Using DEFAULT VALUES" to "INSERT INTO tbl DEFAULT VALUES", | ||
"Explicit bag" to "INSERT INTO tbl << 1, 2, 3 >>", | ||
"Explicit array" to "INSERT INTO tbl [ 1, 2, 3 ]", | ||
"Namespaced table name with delimited alias" to "INSERT INTO \"CaT1\".schema1.\"TBL_1\" AS \"myt\" VALUES (1, 2, 3)", | ||
"Namespaced table name with regular alias" to "INSERT INTO \"CaT1\".schema1.\"TBL_1\" AS myt VALUES (1, 2, 3)", | ||
"Do nothing on conflict" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT DO NOTHING", | ||
"Do nothing on conflict with target index" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT (a, b) DO NOTHING", | ||
"Do nothing on conflict with named constraint" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT ON CONSTRAINT my_constraint DO NOTHING", | ||
"Do replace excluded on conflict" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT DO REPLACE EXCLUDED", | ||
"Do replace excluded on conflict with condition" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT DO REPLACE EXCLUDED WHERE a < 2", | ||
"Do replace excluded on conflict with target index" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT (a, b) DO REPLACE EXCLUDED", | ||
"Do replace excluded on conflict with target index with condition" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT (a, b) DO REPLACE EXCLUDED WHERE a < 2", | ||
"Do replace excluded on conflict with named constraint" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT ON CONSTRAINT my_constraint DO REPLACE EXCLUDED", | ||
"Do replace excluded on conflict with named constraint with condition" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT ON CONSTRAINT my_constraint DO REPLACE EXCLUDED WHERE a < 2", | ||
"Do update excluded on conflict" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT DO UPDATE EXCLUDED", | ||
"Do update excluded on conflict with condition" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT DO UPDATE EXCLUDED WHERE a < 2", | ||
"Do update excluded on conflict with target index" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT (a, b) DO UPDATE EXCLUDED", | ||
"Do update excluded on conflict with target index with condition" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT (a, b) DO UPDATE EXCLUDED WHERE a < 2", | ||
"Do update excluded on conflict with named constraint" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT ON CONSTRAINT my_constraint DO UPDATE EXCLUDED", | ||
"Do update excluded on conflict with named constraint with condition" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT ON CONSTRAINT my_constraint DO UPDATE EXCLUDED WHERE a < 2", | ||
).entries.map { ParserTestCaseSimple(it.key, it.value, isValid = true) } | ||
return m | ||
} | ||
} | ||
|
||
object FailureTestCases : ArgumentsProviderBase() { | ||
override fun getParameters(): List<ParserTestCaseSimple> { | ||
val m = mapOf( | ||
"Lack of table name" to "INSERT INTO VALUES (1, 2, 3)", | ||
"Trailing comma for VALUES" to "INSERT INTO tbl VALUES (1, 2, 3), (4, 5, 6),", | ||
"Not DEFAULT VALUES" to "INSERT INTO tbl DEFAULT VALUE", | ||
"Bad column definitions" to "INSERT INTO tbl (a.b, b, c) VALUES (1, 2, 3)", | ||
"Empty column definitions" to "INSERT INTO tbl () VALUES (1, 2, 3)", | ||
"No values" to "INSERT INTO tbl (a, b) VALUES", | ||
"Bad alias" to "INSERT INTO tbl AS alias1.alias2 (a, b) VALUES", | ||
"Do something on conflict" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT DO SOMETHING", | ||
"No parenthesis on conflict with target index" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT a, b DO NOTHING", | ||
"Bad reference for index on conflict with target index" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT (a, b.c) DO NOTHING", | ||
"Do nothing on conflict with no named constraint" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT ON CONSTRAINT DO NOTHING", | ||
"Do update excluded on conflict with condition in wrong spot" to "INSERT INTO tbl << 1, 2, 3 >> ON CONFLICT WHERE a < 2 DO UPDATE EXCLUDED", | ||
).entries.map { ParserTestCaseSimple(it.key, it.value, isValid = false) } | ||
return m | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,8 @@ class ParserTestCaseSimple( | |
} | ||
} | ||
} | ||
|
||
override fun toString(): String { | ||
return name | ||
} | ||
} |
Oops, something went wrong.