Search in sources :

Example 1 with QualifiedName

use of io.prestosql.spi.sql.expression.QualifiedName in project hetu-core by openlookeng.

the class TestDefaultConnectorConfigFunctionRewriter method testDefaultConnectorConfigFunctionRewriter.

@Test
public void testDefaultConnectorConfigFunctionRewriter() {
    List<String> functionName = new ArrayList<>();
    functionName.add("CORR");
    List<String> argsList = new ArrayList<>();
    argsList.add("var1");
    argsList.add("var2");
    FunctionCallArgsPackage functionCallArgsPackage = new FunctionCallArgsPackage(new QualifiedName(functionName), false, argsList, Optional.empty(), Optional.empty(), Optional.empty());
    String connectorName = "jdbc_connector";
    DefaultUdfRewriteConfigSupplier defaultUdfRewriteConfigSupplier = new DefaultUdfRewriteConfigSupplier(Test_UDF_REWRITE_PATTERNS);
    DefaultConnectorConfigFunctionRewriter defaultConnectorConfigFunctionRewriter = new DefaultConnectorConfigFunctionRewriter(connectorName, defaultUdfRewriteConfigSupplier);
    assertEquals(defaultConnectorConfigFunctionRewriter.rewriteFunctionCall(functionCallArgsPackage), "CORR(var1, var2)");
}
Also used : QualifiedName(io.prestosql.spi.sql.expression.QualifiedName) ArrayList(java.util.ArrayList) DefaultConnectorConfigFunctionRewriter(io.prestosql.sql.builder.functioncall.functions.config.DefaultConnectorConfigFunctionRewriter) DefaultUdfRewriteConfigSupplier(io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier) FunctionCallArgsPackage(io.prestosql.sql.builder.functioncall.FunctionCallArgsPackage) Test(org.testng.annotations.Test)

Example 2 with QualifiedName

use of io.prestosql.spi.sql.expression.QualifiedName in project hetu-core by openlookeng.

the class TestFromBase64CallRewriter method testFromBase64CallRewriter.

@Test
public void testFromBase64CallRewriter() {
    List<String> list = new ArrayList<>();
    list.add("'12A69797965458999E'");
    FunctionCallArgsPackage functionCallArgsPackage = new FunctionCallArgsPackage(new QualifiedName(Collections.emptyList()), false, list, Optional.empty(), Optional.empty(), Optional.empty());
    FromBase64CallRewriter fromBase64CallRewriter = new FromBase64CallRewriter();
    assertEquals(fromBase64CallRewriter.rewriteFunctionCall(functionCallArgsPackage), "D7603AF7BF7BF7AE78E7CF7DF4");
}
Also used : FromBase64CallRewriter(io.prestosql.sql.builder.functioncall.functions.base.FromBase64CallRewriter) QualifiedName(io.prestosql.spi.sql.expression.QualifiedName) ArrayList(java.util.ArrayList) FunctionCallArgsPackage(io.prestosql.sql.builder.functioncall.FunctionCallArgsPackage) Test(org.testng.annotations.Test)

Example 3 with QualifiedName

use of io.prestosql.spi.sql.expression.QualifiedName in project hetu-core by openlookeng.

the class TestBaseFunctionUtil method testFormatQualifiedName.

@Test
public void testFormatQualifiedName() {
    List<String> argsList = new ArrayList<>();
    argsList.add("var1");
    argsList.add("var2");
    QualifiedName qualifiedName = new QualifiedName(argsList);
    assertEquals(BaseFunctionUtil.formatQualifiedName(qualifiedName), "var1.var2");
}
Also used : QualifiedName(io.prestosql.spi.sql.expression.QualifiedName) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 4 with QualifiedName

use of io.prestosql.spi.sql.expression.QualifiedName in project hetu-core by openlookeng.

the class TestConfigFunctionParser method testConfigFunctionParser.

@Test
public void testConfigFunctionParser() {
    String functionName = "LOG10";
    List<String> functionList = new ArrayList<>();
    functionList.add(functionName);
    List<String> argsList = new ArrayList<>();
    argsList.add("var1");
    FunctionCallArgsPackage functionCallArgsPackage = new FunctionCallArgsPackage(new QualifiedName(functionList), false, argsList, Optional.empty(), Optional.empty(), Optional.empty());
    String configPropertyName = ConfigFunctionParser.baseFunctionArgsToConfigPropertyName(functionCallArgsPackage);
    assertEquals(ConfigFunctionParser.baseConfigPropertyValueToFunctionPushDownString(functionCallArgsPackage, UdfPropertiesConstants.Test_UDF_REWRITE_PATTERNS.get(configPropertyName)), "LOG(10, var1)");
}
Also used : QualifiedName(io.prestosql.spi.sql.expression.QualifiedName) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 5 with QualifiedName

use of io.prestosql.spi.sql.expression.QualifiedName in project hetu-core by openlookeng.

the class TestFunctionWriterManagerGroup method testFunctionWriterManagerUnsupportedFunctions.

@Test
public void testFunctionWriterManagerUnsupportedFunctions() {
    String functionName = "LO10";
    List<String> functionList = new ArrayList<>();
    functionList.add(functionName);
    List<String> argsList = new ArrayList<>();
    argsList.add("var1");
    try {
        functionWriterManager1.getFunctionRewriteResult(new QualifiedName(functionList), false, argsList, Optional.empty(), Optional.empty(), Optional.empty());
    } catch (UnsupportedOperationException exception) {
        assertEquals(exception.getMessage(), "jdbc_connector Connector does not support function call of LO10");
    }
}
Also used : QualifiedName(io.prestosql.spi.sql.expression.QualifiedName) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

QualifiedName (io.prestosql.spi.sql.expression.QualifiedName)8 ArrayList (java.util.ArrayList)6 Test (org.testng.annotations.Test)5 DefaultUdfRewriteConfigSupplier (io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier)3 PrestoException (io.prestosql.spi.PrestoException)3 FromBase64CallRewriter (io.prestosql.sql.builder.functioncall.functions.base.FromBase64CallRewriter)3 DefaultConnectorConfigFunctionRewriter (io.prestosql.sql.builder.functioncall.functions.config.DefaultConnectorConfigFunctionRewriter)3 Joiner (com.google.common.base.Joiner)2 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)2 ConfigSupplier (io.prestosql.configmanager.ConfigSupplier)2 BaseJdbcRowExpressionConverter (io.prestosql.plugin.jdbc.optimization.BaseJdbcRowExpressionConverter)2 JdbcConverterContext (io.prestosql.plugin.jdbc.optimization.JdbcConverterContext)2 NOT_SUPPORTED (io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED)2 FunctionHandle (io.prestosql.spi.function.FunctionHandle)2 FunctionMetadata (io.prestosql.spi.function.FunctionMetadata)2 FunctionMetadataManager (io.prestosql.spi.function.FunctionMetadataManager)2 OperatorType (io.prestosql.spi.function.OperatorType)2 StandardFunctionResolution (io.prestosql.spi.function.StandardFunctionResolution)2 CallExpression (io.prestosql.spi.relation.CallExpression)2 ConstantExpression (io.prestosql.spi.relation.ConstantExpression)2