-
Notifications
You must be signed in to change notification settings - Fork 62
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
Dumps the ported typer tests and adds appropriate testing mechanisms. #1574
base: v1
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These slight changes made it easier to serialize the tests.
import org.partiql.planner.test.TestProviderBuilder | ||
import java.util.stream.Stream | ||
|
||
class TyperTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the replacement for PlanTyperTestsPorted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to confirm all of the existing tests are included in TyperTests
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job w/ porting the tests! Most comments/questions were about some missing context and possible simplifications
import org.partiql.planner.test.TestProviderBuilder | ||
import java.util.stream.Stream | ||
|
||
class TyperTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to confirm all of the existing tests are included in TyperTests
?
fun print() { | ||
val other = PlanTyperTestsPorted.TestProvider().provideArguments(null).map { it.get()[0] as PlanTyperTestsPorted.TestCase }.toList() | ||
val testCases = | ||
other + PlanTyperTestsPorted.collections() + PlanTyperTestsPorted.decimalCastCases() + PlanTyperTestsPorted.selectStar() + PlanTyperTestsPorted.sessionVariables() + PlanTyperTestsPorted.bitwiseAnd() + PlanTyperTestsPorted.unpivotCases() + PlanTyperTestsPorted.joinCases() + PlanTyperTestsPorted.excludeCases() + PlanTyperTestsPorted.orderByCases() + PlanTyperTestsPorted.tupleUnionCases() + PlanTyperTestsPorted.aggregationCases() + PlanTyperTestsPorted.scalarFunctions() + PlanTyperTestsPorted.distinctClauseCases() + PlanTyperTestsPorted.pathExpressions() + PlanTyperTestsPorted.caseWhens() + PlanTyperTestsPorted.nullIf() + PlanTyperTestsPorted.coalesce() + PlanTyperTestsPorted.subqueryCases() + PlanTyperTestsPorted.dynamicCalls() + PlanTyperTestsPorted.scanCases() + PlanTyperTestsPorted.pivotCases() + PlanTyperTestsPorted.isTypeCases() + PlanTyperTestsPorted.castCases() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this currently spans one line. could break it up for better readability
interface Test { | ||
|
||
/** | ||
* @return the name of the test. | ||
*/ | ||
fun getName(): String | ||
|
||
/** | ||
* Should throw an exception if a failure occurs. | ||
*/ | ||
fun assert() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we foresee future Test
implementations other than TyperTest
? I feel like it's slight overkill to have a broader Test
interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The reason we'd like to do this is to create a starting point by which we may serialize all of our tests in a uniform manner. For execution, typing, etc.
* @see StructElement | ||
* @see PartiQLTestProvider | ||
*/ | ||
interface TestBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly for the TestBuilder
and TestBuilderFactory
, seems like a lot of additional boilerplate unless we foresee adding more than the typing tests within partiql-planner
?
cwd:[ | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vast majority of the typing tests use an empty session directory list. Wonder if we could simplify the logic by making a non-specified cwd
equivalent to an empty session directory list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this! I'll update.
@@ -23,6 +23,7 @@ import kotlin.io.path.toPath | |||
* The PartiQLTestProvider is a simple utility for indexing SQL statements within files for re-use across library tests. | |||
*/ | |||
class PartiQLTestProvider { | |||
// TODO: Rename this to StatementProvider to better reflect its purpose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could address in this PR?
private fun getQualifier(): Array<String> { | ||
return _qualifier | ||
} | ||
|
||
private fun getName(): String { | ||
return _name | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these getters necessary? Since this is just in the tests, this indirection is not needed. I feel like it would be much simpler to just directly reference the _qualifer
and _name
.
@@ -0,0 +1,6717 @@ | |||
|
|||
test::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point could be helpful to break into different files and/or namespaces like the conformance tests currently do. We could track in some TODO/issue.
} | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could provide the description of the test format in some other more visible location such as https://github.com/johnedquinn/partiql-lang-jvm/blob/v1-tests-dump/partiql-planner/src/testFixtures/resources/README.adoc.
Something like https://github.com/partiql/partiql-tests/blob/main/docs/partiql-tests-schema-proposal.md#evaluation-tests, could make it easier to add future tests.
@@ -0,0 +1,236 @@ | |||
package org.partiql.planner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some broader questions for porting the typing tests since I may be missing some context.
- Is the goal here to eventually delete the
PlanTyperTestsPorted
(and related files)? - Where will the ported typing tests eventually live? In the conformance test suite?
- At what point will we delete the existing
PlanTyperTestsPorted
(and related files)? - For future plan typing tests we want to add, what's the process for adding a test? Just add the test to the
plan-typer-tests-ported.ion
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Yes.
- I'd personally like to extract these interfaces into another package:
test/partiql-test-interfaces
that can be imported as a test dependency across the project. Any particular subproject may have local serialized tests -- and once the team agrees upon the tests' correctness, they can be moved into the conformance test suite. If you'd like, I can move these interfaces immediately in this PR. - The only open action item for
PlanTyperTestsPorted
has to do with the serialization of errors, which is being worked on. I actually don't need to keep it right now. I can always resurface thePrintPlanTyperTestsPorted
from an older commit to re-serialize when the error serialization is addressed. - You can add a test to the
tests
directory in any file you'd like.
Description
Structure
tests
name
,type
, andbody
. Thetype
is used to request theTestBuilderFactory
whichTestBuilder
to use. Thename
, in combination with the path to the test file, is used to create aTestId
. Thebody
(a struct) is passed to theTestBuilder
to allow for user-defined tests.TyperTests
just invokes theTestProvider
to deserialize the tests and shuttle them through JUnit.Other Information
and Code Style Guidelines? YES
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.