-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Enable UDF access to SQLTransformers #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enable UDF access to SQLTransformers #202
Conversation
Currently in Dagger Flink sql-query we can access all the java and python based UDF functions. But the same UDF functions are not accessible in the post-processor(SQLTransformer). The Flink API StreamTableEnvironment instance is used to register the UDF function in method call registerFunctions() in StreamManager.java class. Since the same instance is not used to create Flink tables in SQLTransformer.java class, due to which UDFs are not accessible. We can solve this by two approaches as below. Approach-1: We can introduce the DaggerContext singleton object which holds the StreamExecutionEnvironment, StreamTableEnvironment and Configuration instance variables, we can use these variables throughout the application.This context object gets initialized only once in driver class KafkaProtoSQLProcessor.java. We can call the DaggerContext object as a static method call in the Transformer.java interface. With this DaggerContext we can register the Flink table in SQLTransformer.java. And can have access to the UDFs which were registered earlier. Approach-2: In SQLTransformer.java class we can create a new instance of StreamManager and call registerFunctions method for each SQLTransformer configuration. With this approach, if the user calls n times SqlTransformer configuration, then n times the registration of UDFs get called and n times Objects are initialized. Here we have followed Approach-1.
dagger-common/src/main/java/io/odpf/dagger/common/core/Transformer.java
Outdated
Show resolved
Hide resolved
dagger-functions/src/main/java/io/odpf/dagger/functions/transformers/SQLTransformer.java
Outdated
Show resolved
Hide resolved
KafkaProtoSQLProcessor -> StreamManager -> PostProcessorFactory -> ParentPostProcessor -> TransformProcessor and refactoring related code
| import io.odpf.dagger.common.core.DaggerContextTestBase; | ||
| import org.apache.flink.api.java.utils.ParameterTool; | ||
| import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; | ||
| //import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this import been commented ?
I can see its still used in Line 50 below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been un-commented and handled.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Currently in Dagger Flink sql-query we can access all the java and python based UDF functions. But the same UDF functions are not accessible in the post-processor(SQLTransformer).
The Flink API StreamTableEnvironment instance is used to register the UDF function in method call registerFunctions() in StreamManager.java class. Since the same instance is not used to create Flink tables in SQLTransformer.java class, due to which UDFs are not accessible.
We can solve this by two approaches as below.
Approach-1:
We can introduce the DaggerContext singleton object which holds the StreamExecutionEnvironment, StreamTableEnvironment and Configuration instance variables, we can use these variables throughout the application.This context object gets initialized only once in driver class KafkaProtoSQLProcessor.java.
We can call the DaggerContext object as a static method call in the Transformer.java interface. With this DaggerContext we can register the Flink table in SQLTransformer.java. And can have access to the UDFs which were registered earlier.
Approach-2:
In SQLTransformer.java class we can create a new instance of StreamManager and call registerFunctions method for each SQLTransformer configuration. With this approach, if the user calls n times SqlTransformer configuration, then n times the registration of UDFs get called and n times Objects are initialized.
Here we have followed Approach-1.