Skip to content
Prev Previous commit
Next Next commit
Simplify filter
  • Loading branch information
petermaxlee committed Aug 10, 2016
commit 7497742617420da77932fe20fff3d422b1a52fde
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {
// val cleaned = input.split("\n").filterNot(_.matches("--.*(?<=[^\\\\]);")).mkString("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

val cleaned = input.split("\n").filterNot(_.startsWith("--")).mkString("\n")
// note: this is not a robust way to split queries using semicolon, but works for now.
cleaned.split("(?<=[^\\\\]);").map(_.trim).filterNot(q => q == "").toSeq
cleaned.split("(?<=[^\\\\]);").map(_.trim).filter(_ != "").toSeq
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain a bit more about this regex? Why can't we just use ; here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from HiveComparisonTest. I think it is done to avoid escaping e.g. ";". It is really not very robust, but seems fine for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain a bit more about this regex? Why can't we just use ; here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from HiveComparisonTest. I think it is done to avoid escaping e.g. ";". It is really not very robust, but seems fine for now.

}

// Run the SQL queries preparing them for comparison.
Expand Down