-
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
feat: change the public API of schema provider method #3287
Conversation
@confluentinc It looks like @vpapavas just signed our Contributor License Agreement. 👍 Always at your service, clabot |
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.
LGTM! Not sure I understand the dependency changes though
@@ -177,9 +178,11 @@ private void checkMatchingReturnTypes(final Schema s1, final Schema s2) { | |||
if (!SchemaUtil.areCompatible(s1, s2)) { | |||
throw new KsqlException(String.format("Return type %s of UDF %s does not match the declared " | |||
+ "return type %s.", | |||
s1.toString(), | |||
SchemaConverters.connectToSqlConverter().toSqlType( |
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 think it may actually be preferable to use the SqlType#toString instead of converting it to Connect schema first! That way the user gets ARRAY<INTEGER>
in sql syntax.
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.
Yep, the new SqlType
s have a toString
and toString(FormatOptions)
and output correct SQL.
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 am actually converting from Schema to SqlType so that the user gets the message in sql syntax
ksql-engine/pom.xml
Outdated
@@ -167,6 +167,14 @@ | |||
<artifactId>wiremock-jre8</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.confluent.ksql</groupId> | |||
<artifactId>ksql-streams</artifactId> |
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.
?
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.
Don't think this is needed
@@ -69,6 +69,10 @@ | |||
<version>${project.version}</version> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.confluent.ksql</groupId> | |||
<artifactId>ksql-common</artifactId> |
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.
?
return parameterTypes -> { | ||
return invokeSchemaProviderMethod(instance, m, parameterTypes, annotation); | ||
return parameterSchemas -> { | ||
final List<SqlType> parameterTypes = parameterSchemas.stream().map(p -> SchemaConverters |
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.
nit: with multi-statement streams it's much easier to read on multiple lines
parameterSchemas.stream()
.map(p -> ...)
.collect(...)
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.
+1
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.
LGTM!
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.
LGTM, except for the dependency changes.
Thanks for making this change - I think it's worth it - much better public API and better error messages too!
@@ -177,9 +178,11 @@ private void checkMatchingReturnTypes(final Schema s1, final Schema s2) { | |||
if (!SchemaUtil.areCompatible(s1, s2)) { | |||
throw new KsqlException(String.format("Return type %s of UDF %s does not match the declared " | |||
+ "return type %s.", | |||
s1.toString(), | |||
SchemaConverters.connectToSqlConverter().toSqlType( |
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.
Yep, the new SqlType
s have a toString
and toString(FormatOptions)
and output correct SQL.
ksql-engine/pom.xml
Outdated
@@ -167,6 +167,14 @@ | |||
<artifactId>wiremock-jre8</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.confluent.ksql</groupId> | |||
<artifactId>ksql-streams</artifactId> |
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.
Don't think this is needed
return parameterTypes -> { | ||
return invokeSchemaProviderMethod(instance, m, parameterTypes, annotation); | ||
return parameterSchemas -> { | ||
final List<SqlType> parameterTypes = parameterSchemas.stream().map(p -> SchemaConverters |
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.
+1
final Schema s = params.get(0); | ||
if (!DecimalUtil.isDecimal(s)) { | ||
final SqlType s = params.get(0); | ||
if (!(s.baseType() == SqlBaseType.DECIMAL)) { |
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.
if (!(s.baseType() == SqlBaseType.DECIMAL)) { | |
if (s.baseType() != SqlBaseType.DECIMAL) { |
32f4c8c
to
64b9847
Compare
Description
Changed the signature of
Schema provideSchema(List<Schema>)
to use SqlType instead.I updated the docs as well.
Testing done
No new tests added, updated existing ones.
Reviewer checklist