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: display precision and scale when describing DECIMAL columns #6872

Conversation

swist
Copy link
Member

@swist swist commented Jan 15, 2021

Description

Fixes #6843
We want DESCRIBE queries to show the precision and scale for DECIMAL columns

It seems to me that maybe it would make sense to carry instances of
SqlBaseType on SchemaInfo instances somehow so that we could delegate
these formatting duties to them?

Testing done

  • new unit tests added

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 #")

@swist swist requested a review from a team as a code owner January 15, 2021 19:06
@ghost
Copy link

ghost commented Jan 15, 2021

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

Always at your service,

clabot

@swist swist requested a review from agavra January 15, 2021 19:06
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.

Thanks @swist! I think this is a great first pass at the PR - no major comments inline, some recommendations about testing and java-isms.

In general, any PR that changes something that is visible to the user in the CLI should have a copy-paste terminal session in the "testing done" so that we can see what it would look like from the user perspective. Something like:

ksql> describe s;

 Name                 : S
 Field | Type
-----------------
 VAL   | DECIMAL(5, 2)
-----------------

@swist swist force-pushed the ksql-6843/show-decimal-precision-in-describe-output branch from 326960a to ad6588b Compare January 16, 2021 16:07
+ " \"memberSchema\" : null" + NEWLINE
+ " }" + NEWLINE
+ " \"memberSchema\" : null," + NEWLINE
+ " \"parameters\" : { }" + NEWLINE
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a less crappy way of validating json returns? Load from file? (would also be good if it was order invariant, but i'm guessing in Java it will be fixed wrt to order in which the AST is walked?)

Copy link
Contributor

@agavra agavra Jan 19, 2021

Choose a reason for hiding this comment

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

a less crappy way would also be when we eventually upgrade to java 13 to get multiline strings https://openjdk.java.net/jeps/355

(would also be good if it was order invariant, but i'm guessing in Java it will be fixed wrt to order in which the AST is walked?)

I guess what we could do here is load our string as a JSON object and then use jackson to compare them

@swist swist force-pushed the ksql-6843/show-decimal-precision-in-describe-output branch 2 times, most recently from 5ff9ece to ad1a473 Compare January 18, 2021 15:17
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-guava</artifactId>
<version>2.10.5</version>
Copy link
Member Author

Choose a reason for hiding this comment

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

This adds support for guava serdes in jackson

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we keep all of the versions as properties in the ksqldb-parent pom so that we can reference them all in one place

though perhaps more importantly, I'm not sure I understand why we need the guava serdes?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need the guava series because jackson otherwise doesn't understand how to serde an ImmutableMap

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you get around that by declaring it as a Map (not ImmutableMap and just in the body of the method wrap it with ImmutableMap.copyOf()? In general, it's better practice to use interfaces in the fields/public accessors than the implementation class

Copy link
Contributor

Choose a reason for hiding this comment

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

Unresolved this one as I feel that it may still be relevant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ow shoot, only saw it after I pressed the big green button. I don't remember exactly, but I think it would work now that you've showed me how to mark it as @EffectivelyImmutable. Do you want me to do a follow up PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

no worries - I think a quick follow-up PR would be ideal. fewer dependencies is a good thing for build speed and package size :)

@swist swist force-pushed the ksql-6843/show-decimal-precision-in-describe-output branch from ad1a473 to f1bee05 Compare January 18, 2021 15:41
@swist swist requested a review from agavra January 19, 2021 09:24
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! Some minor replies left on the previous comments, and I'm not sure I understand why we need the GuavaModule

@swist swist force-pushed the ksql-6843/show-decimal-precision-in-describe-output branch from f1bee05 to 2af0181 Compare January 19, 2021 19:25
@swist swist merged commit fb89998 into confluentinc:master Jan 20, 2021
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.

Show decimal field precision/scale in DESCRIBE output
2 participants