-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add UDF support to import/export workflows #2253
base: main
Are you sure you want to change the base?
Conversation
Hoping to fix test failures in v2/
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (59.13%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2253 +/- ##
============================================
+ Coverage 48.83% 48.87% +0.03%
- Complexity 4514 4542 +28
============================================
Files 905 907 +2
Lines 55061 55290 +229
Branches 5881 5921 +40
============================================
+ Hits 26891 27024 +133
- Misses 26251 26335 +84
- Partials 1919 1931 +12
🚀 New features to boost your workflow:
|
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.
Changes look good overall. Left few comments, Please take a look.
@@ -143,6 +153,31 @@ public View toView(String viewName, Schema schema) { | |||
return builder.build(); | |||
} | |||
|
|||
public Udf toUdf(String functionSpecificName, Schema schema) { |
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.
What is functionSpecificName?
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.
That would be the full name, including the schema/namespace prefix
recordBuilder.prop(SPANNER_NAME, udf.specificName()); | ||
recordBuilder.prop(GOOGLE_FORMAT_VERSION, version); | ||
recordBuilder.prop(GOOGLE_STORAGE, "CloudSpanner"); | ||
// Indicate that this is a "CREATE FUNCTION", not a table or a view. |
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.
Just checking, is this a TODO comment?
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.
No, it's just pointing out that this property is to distinguish the type of object
@@ -490,6 +491,7 @@ public void processElement(ProcessContext c) { | |||
List<KV<String, Schema>> missingViews = new ArrayList<>(); | |||
List<KV<String, Schema>> missingChangeStreams = new ArrayList<>(); | |||
List<KV<String, Schema>> missingSequences = new ArrayList<>(); | |||
List<KV<String, Schema>> missingFunctions = new ArrayList<>(); |
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.
Since we are calling it UDF in other places, Lets call it UDFs everywhere? rename to missingUDFs
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.
Renamed
mergedDdl.addUdf(udf); | ||
} | ||
Ddl newDdl = builder.build(); | ||
ddlStatements.addAll(newDdl.createUdfStatements()); |
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.
I see that the missingTables and views are getting added to ddlStatements in Next lines. If UDFs would depend on tables, views etc, they should added to ddlStatements later. The order of statements in ddlStatements matters.
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 is intentional, the plan is to initially only support "UDF_without_SELECT"
@@ -798,6 +817,12 @@ public void processElement(ProcessContext c) { | |||
c.output(KV.of(sequence.getName(), fullPath)); | |||
} | |||
} | |||
for (Export.Table udf : proto.getFunctionsList()) { |
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.
The proto here is Export.proto is it? We should call it udf
consistently everywhere.
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.
Updated
@@ -1004,6 +1008,112 @@ private void listViews(Ddl.Builder builder) { | |||
} | |||
} | |||
|
|||
private void listFunctions(Ddl.Builder builder) { |
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.
Please confirm that all the information schema table names, and columns used in the queries here are present in production. Also, can you get the changes in this file reviewed by one of your team members?
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.
Confirmed, and @seanfox agreed to review these changes
@@ -1004,6 +1008,112 @@ private void listViews(Ddl.Builder builder) { | |||
} | |||
} | |||
|
|||
private void listFunctions(Ddl.Builder builder) { |
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.
Also, please add unit tests for changes in this file. In InformationSchemaScannerTest.java
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.
Added testListFunctionParametersSQL
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.cloud.teleport.spanner.ddl; |
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.
Please add unit tests and cover all the lines in this file.
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.
Added UdfTest.java
@@ -0,0 +1,136 @@ | |||
/* |
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.
Please add unit tests and cover all the lines in this file.
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.
Added UdfParameterTest.java
@@ -30,7 +30,7 @@ message Export { | |||
// change stream or sequence name. Both `data_files` and `manifest_file` can | |||
// be used to locate the corresponding data files. | |||
message Table { | |||
// The name of the table, view, change stream or sequence. | |||
// The name of the table, view, change stream, sequence, or function. |
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.
Please call this as udf for consistency.
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.
Updated
Adding support for User Defined Functions (UDFs) to be imported from and exported to Avro files. Supported format follows the syntax -