Skip to content

Commit

Permalink
Extract method for processing input string in test
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiafi committed Jan 21, 2022
1 parent 3fab98f commit 5344c78
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,16 @@ public void testCastRealToBoundedVarchar()

private static void assertSimplifies(String expression, String expected)
{
ParsingOptions parsingOptions = new ParsingOptions();
Expression actualExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expression, parsingOptions));
Expression expectedExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expected, parsingOptions));
Expression rewritten = rewrite(actualExpression, TEST_SESSION, new SymbolAllocator(booleanSymbolTypeMapFor(actualExpression)), PLANNER_CONTEXT, createTestingTypeAnalyzer(PLANNER_CONTEXT));
Expression expectedExpression = normalize(rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expected, new ParsingOptions())));
assertEquals(
normalize(rewritten),
normalize(expectedExpression));
simplify(expression),
expectedExpression);
}

private static Expression simplify(String expression)
{
Expression actualExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expression, new ParsingOptions()));
return normalize(rewrite(actualExpression, TEST_SESSION, new SymbolAllocator(booleanSymbolTypeMapFor(actualExpression)), PLANNER_CONTEXT, createTestingTypeAnalyzer(PLANNER_CONTEXT)));
}

private static Map<Symbol, Type> booleanSymbolTypeMapFor(Expression expression)
Expand Down

0 comments on commit 5344c78

Please sign in to comment.