Skip to content
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

Merged
merged 5 commits into from
Sep 4, 2019

Conversation

vpapavas
Copy link
Member

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

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@vpapavas vpapavas requested review from JimGalasyn and a team as code owners August 29, 2019 21:11
@ghost
Copy link

ghost commented Aug 29, 2019

@confluentinc It looks like @vpapavas just signed our Contributor License Agreement. 👍

Always at your service,

clabot

@vpapavas vpapavas requested a review from agavra August 29, 2019 21:13
Copy link
Contributor

@agavra agavra left a 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(
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the new SqlTypes have a toString and toString(FormatOptions) and output correct SQL.

Copy link
Member Author

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

@@ -167,6 +167,14 @@
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.confluent.ksql</groupId>
<artifactId>ksql-streams</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

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>
Copy link
Contributor

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
Copy link
Contributor

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(...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@agavra agavra requested a review from a team August 29, 2019 22:16
Copy link
Member

@JimGalasyn JimGalasyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@big-andy-coates big-andy-coates left a 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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the new SqlTypes have a toString and toString(FormatOptions) and output correct SQL.

@@ -167,6 +167,14 @@
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.confluent.ksql</groupId>
<artifactId>ksql-streams</artifactId>
Copy link
Contributor

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
Copy link
Contributor

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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!(s.baseType() == SqlBaseType.DECIMAL)) {
if (s.baseType() != SqlBaseType.DECIMAL) {

@vpapavas vpapavas changed the title improvement: Change the public API of schema provider method improvement: change the public API of schema provider method Sep 4, 2019
@vpapavas vpapavas changed the title improvement: change the public API of schema provider method feat: change the public API of schema provider method Sep 4, 2019
@vpapavas vpapavas merged commit 1324285 into confluentinc:master Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants