Search in sources :

Example 1 with DefaultUdfRewriteConfigSupplier

use of io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier in project hetu-core by openlookeng.

the class TestFunctionWriterManagerGroup method setUp.

@BeforeTest
public void setUp() {
    String connectorName = "jdbc_connector";
    String versionName = "default";
    Map<String, FunctionCallRewriter> functionCallRewriterMap = new HashMap<>();
    functionCallRewriterMap.put(VarbinaryLiteralFunctionCallRewriterForUt.INNER_FUNC_VARBINARY_LITERAL, new VarbinaryLiteralFunctionCallRewriterForUt());
    functionCallRewriterMap.put(UnsupportedFunctionCallRewriterForUt.UNSUPPORTED_FUNCTION_NAME_TEST, new UnsupportedFunctionCallRewriterForUt(connectorName));
    DefaultUdfRewriteConfigSupplier defaultUdfRewriteConfigSupplier = new DefaultUdfRewriteConfigSupplier(Test_UDF_REWRITE_PATTERNS);
    DefaultConnectorConfigFunctionRewriter defaultConnectorConfigFunctionRewriter = new DefaultConnectorConfigFunctionRewriter(connectorName, defaultUdfRewriteConfigSupplier);
    setFunctionWriterManager(connectorName, versionName, functionCallRewriterMap, defaultConnectorConfigFunctionRewriter);
    FunctionWriterManager functionWriterManager2 = FunctionWriterManagerGroup.newFunctionWriterManagerInstance(connectorName, versionName, functionCallRewriterMap, defaultConnectorConfigFunctionRewriter);
    assertEquals(functionWriterManager1.toString(), functionWriterManager2.toString());
}
Also used : FunctionCallRewriter(io.prestosql.sql.builder.functioncall.functions.FunctionCallRewriter) HashMap(java.util.HashMap) UnsupportedFunctionCallRewriterForUt(io.prestosql.sql.builder.functioncall.base.UnsupportedFunctionCallRewriterForUt) DefaultConnectorConfigFunctionRewriter(io.prestosql.sql.builder.functioncall.functions.config.DefaultConnectorConfigFunctionRewriter) DefaultUdfRewriteConfigSupplier(io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with DefaultUdfRewriteConfigSupplier

use of io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier 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 3 with DefaultUdfRewriteConfigSupplier

use of io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier in project hetu-core by openlookeng.

the class ClickHouseRowExpressionConverter method initFunctionManager.

private FunctionWriterManager initFunctionManager(ClickHouseConfig clickHouseConfig) {
    ConfigSupplier configSupplier = new DefaultUdfRewriteConfigSupplier(UdfFunctionRewriteConstants.DEFAULT_VERSION_UDF_REWRITE_PATTERNS);
    DefaultConnectorConfigFunctionRewriter connectorConfigFunctionRewriter = new DefaultConnectorConfigFunctionRewriter(ClickHouseConstants.CONNECTOR_NAME, configSupplier);
    return FunctionWriterManagerGroup.newFunctionWriterManagerInstance(ClickHouseConstants.CONNECTOR_NAME, clickHouseConfig.getClickHouseSqlVersion(), getInjectFunctionCallRewritersDefault(clickHouseConfig), connectorConfigFunctionRewriter);
}
Also used : ConfigSupplier(io.prestosql.configmanager.ConfigSupplier) DefaultUdfRewriteConfigSupplier(io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier) DefaultConnectorConfigFunctionRewriter(io.prestosql.sql.builder.functioncall.functions.config.DefaultConnectorConfigFunctionRewriter) DefaultUdfRewriteConfigSupplier(io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier)

Example 4 with DefaultUdfRewriteConfigSupplier

use of io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier in project hetu-core by openlookeng.

the class HanaRowExpressionConverter method initFunctionManager.

private FunctionWriterManager initFunctionManager(HanaConfig hanaConfig) {
    // add inner config udf, use the default function result string builder in the HanaConfigUdfRewriter
    ConfigSupplier configSupplier = new DefaultUdfRewriteConfigSupplier(UdfFunctionRewriteConstants.DEFAULT_VERSION_UDF_REWRITE_PATTERNS);
    DefaultConnectorConfigFunctionRewriter connectorConfigFunctionRewriter = new DefaultConnectorConfigFunctionRewriter(HanaConstants.CONNECTOR_NAME, configSupplier);
    // use the default function Signature Builder in the HanaFunctionRewriterManager
    return FunctionWriterManagerGroup.newFunctionWriterManagerInstance(HanaConstants.CONNECTOR_NAME, hanaConfig.getHanaSqlVersion(), getInjectFunctionCallRewritersDefault(hanaConfig), connectorConfigFunctionRewriter);
}
Also used : ConfigSupplier(io.prestosql.configmanager.ConfigSupplier) DefaultUdfRewriteConfigSupplier(io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier) DefaultConnectorConfigFunctionRewriter(io.prestosql.sql.builder.functioncall.functions.config.DefaultConnectorConfigFunctionRewriter) DefaultUdfRewriteConfigSupplier(io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier)

Aggregations

DefaultUdfRewriteConfigSupplier (io.prestosql.configmanager.DefaultUdfRewriteConfigSupplier)4 DefaultConnectorConfigFunctionRewriter (io.prestosql.sql.builder.functioncall.functions.config.DefaultConnectorConfigFunctionRewriter)4 ConfigSupplier (io.prestosql.configmanager.ConfigSupplier)2 QualifiedName (io.prestosql.spi.sql.expression.QualifiedName)1 FunctionCallArgsPackage (io.prestosql.sql.builder.functioncall.FunctionCallArgsPackage)1 UnsupportedFunctionCallRewriterForUt (io.prestosql.sql.builder.functioncall.base.UnsupportedFunctionCallRewriterForUt)1 FunctionCallRewriter (io.prestosql.sql.builder.functioncall.functions.FunctionCallRewriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1