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

#34 Support Update Statement #97

Merged
merged 6 commits into from
Oct 15, 2016

Conversation

OmniaGM
Copy link
Member

@OmniaGM OmniaGM commented Oct 6, 2016

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.8%) to 77.964% when pulling 8a1d413 on OmniaGM:feature/34-update-statment into 21b4618 on cassandra-scala:master.

@OmniaGM OmniaGM added this to the 0.4 milestone Oct 8, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 78.488% when pulling c33fabc on OmniaGM:feature/34-update-statment into 21b4618 on cassandra-scala:master.

Copy link
Member

@tabdulradi tabdulradi left a comment

Choose a reason for hiding this comment

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

Few changes, and corner cases to test.

@@ -68,4 +69,18 @@ class UpdateStatementParserTest extends FlatSpec with Matchers {
simpleRelation2.term.asInstanceOf[Constant].raw shouldBe "click"

}

it should "parse update statement with list literal assignment" in {
Copy link
Member

Choose a reason for hiding this comment

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

Please add more test cases for the parser. Also, test for BindMarkers in different places of the statement.

@@ -32,6 +32,12 @@ object Messages {
// Validations
case class SelectedDistinctNonStaticColumn(c: Identifier) extends Message(s"SELECT DISTINCT queries must only request partition key columns and/or static columns (not $c)")

// TODO: Format Term
Copy link
Member

Choose a reason for hiding this comment

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

Please move those new classes to line 26.

schema.getTable(s.tableName).flatMap { table =>
V.merge(Seq(
extractVariablesFomSet(table, s.set),
extractVariablesFromUpdateParam(table, s.using),
Copy link
Member

Choose a reason for hiding this comment

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

Wrong order. Variables in USING should appear before variables in SET.
Please first write test cases to expose the problem.


private def extractVariablesFromEitherListLiteralOrBindMarker(table: Table, columnName: Identifier, literalOrBindMarker: Either[ListLiteral, BindMarker]): Result[Seq[DataType]] = {
literalOrBindMarker match {
case Left(listLiteral) => extractVariablesFromListLiteralAssignment(table, columnName, listLiteral)
Copy link
Member

Choose a reason for hiding this comment

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

Please add a todo to validate that column is actually a list.

private def extractVariablesFromTermAssigment(table: Table, columnName: Identifier, updateOperator: Update.UpdateOperator, term: Term): Result[Seq[DataType]] =
table.getColumn(columnName).map(_.dataType).flatMap {
case DataType.List(t) => extractVariablesFromTerm(term, DataType.List(t))
case DataType.Map(k, t) => extractVariablesFromTerm(term, DataType.Map(k, t))
Copy link
Member

Choose a reason for hiding this comment

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

What about DataType.Set?

@OmniaGM
Copy link
Member Author

OmniaGM commented Oct 9, 2016

@tabdulradi done, check the new commits please.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.5%) to 78.665% when pulling 95c9c9a on OmniaGM:feature/34-update-statment into 21b4618 on cassandra-scala:master.

@tabdulradi
Copy link
Member

Please write a test case for the variable order bug first.
Also, please an Integration test under the troy-macro subproject to ensure Update is fully working.

@coveralls
Copy link

Coverage Status

Coverage increased (+11.0%) to 87.172% when pulling d334d0f on OmniaGM:feature/34-update-statment into 21b4618 on cassandra-scala:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+11.1%) to 87.318% when pulling 865a1ba on OmniaGM:feature/34-update-statment into 21b4618 on cassandra-scala:master.

@tabdulradi tabdulradi merged commit bbb4abe into schemasafe:master Oct 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants