use of com.facebook.presto.expressions.translator.TranslatedExpression in project presto by prestodb.
the class TestRowExpressionTranslator method testMissingFunctionTranslator.
@Test
public void testMissingFunctionTranslator() {
String untranslated = "ABS(col1)";
TypeProvider typeProvider = TypeProvider.copyOf(ImmutableMap.of("col1", DOUBLE));
RowExpression specialForm = sqlToRowExpressionTranslator.translate(expression(untranslated), typeProvider);
TranslatedExpression translatedExpression = translateWith(specialForm, new TestFunctionTranslator(functionAndTypeManager, buildFunctionTranslator(ImmutableSet.of(TestFunctions.class))), emptyMap());
assertFalse(translatedExpression.getTranslated().isPresent());
}
use of com.facebook.presto.expressions.translator.TranslatedExpression in project presto by prestodb.
the class TestRowExpressionTranslator method testLessThanOperator.
@Test
public void testLessThanOperator() {
String untranslated = "col1 < col2";
TypeProvider typeProvider = TypeProvider.copyOf(ImmutableMap.of("col1", BIGINT, "col2", BIGINT));
RowExpression specialForm = sqlToRowExpressionTranslator.translate(expression(untranslated), typeProvider);
TranslatedExpression translatedExpression = translateWith(specialForm, new TestFunctionTranslator(functionAndTypeManager, buildFunctionTranslator(ImmutableSet.of(TestFunctions.class))), emptyMap());
assertTrue(translatedExpression.getTranslated().isPresent());
assertEquals(translatedExpression.getTranslated().get(), "col1 LT col2");
}
use of com.facebook.presto.expressions.translator.TranslatedExpression in project presto by prestodb.
the class TestRowExpressionTranslator method testEndToEndFunctionTranslation.
@Test
public void testEndToEndFunctionTranslation() {
String untranslated = "LN(bitwise_and(1, col1))";
TypeProvider typeProvider = TypeProvider.copyOf(ImmutableMap.of("col1", BIGINT));
CallExpression callExpression = (CallExpression) sqlToRowExpressionTranslator.translate(expression(untranslated), typeProvider);
TranslatedExpression translatedExpression = translateWith(callExpression, new TestFunctionTranslator(functionAndTypeManager, buildFunctionTranslator(ImmutableSet.of(TestFunctions.class))), emptyMap());
assertTrue(translatedExpression.getTranslated().isPresent());
assertEquals(translatedExpression.getTranslated().get(), "LNof(1 BITWISE_AND col1)");
}
use of com.facebook.presto.expressions.translator.TranslatedExpression in project presto by prestodb.
the class TestRowExpressionTranslator method testHiddenFunctionNot.
@Test
public void testHiddenFunctionNot() {
String untranslated = "NOT true";
RowExpression specialForm = sqlToRowExpressionTranslator.translate(expression(untranslated), TypeProvider.empty());
TranslatedExpression translatedExpression = translateWith(specialForm, new TestFunctionTranslator(functionAndTypeManager, buildFunctionTranslator(ImmutableSet.of(TestFunctions.class))), emptyMap());
assertTrue(translatedExpression.getTranslated().isPresent());
assertEquals(translatedExpression.getTranslated().get(), "NOT_2 true");
}
use of com.facebook.presto.expressions.translator.TranslatedExpression in project presto by prestodb.
the class TestRowExpressionTranslator method testIncorrectFunctionSignatureInDefinition.
@Test
public void testIncorrectFunctionSignatureInDefinition() {
String untranslated = "CEIL(col1)";
TypeProvider typeProvider = TypeProvider.copyOf(ImmutableMap.of("col1", DOUBLE));
RowExpression specialForm = sqlToRowExpressionTranslator.translate(expression(untranslated), typeProvider);
TranslatedExpression translatedExpression = translateWith(specialForm, new TestFunctionTranslator(functionAndTypeManager, buildFunctionTranslator(ImmutableSet.of(TestFunctions.class))), emptyMap());
assertFalse(translatedExpression.getTranslated().isPresent());
}
Aggregations