NIFI-7462: QueryRecord cast functions for Choice datatypes#4280
NIFI-7462: QueryRecord cast functions for Choice datatypes#4280pcgrenier wants to merge 1 commit intoapache:masterfrom
Conversation
…valid type for use with calcite query functions
|
Will review |
|
Hey @pcgrenier thanks for putting this PR up. I do think that it addresses the case when all of the values coming in have the same type. But if your schema says that field 'num' can be either an int or a float, this solutions forces the user to cast all values to either int or float. It stands to reason that with such a schema, you could have a mix of both ints and floats. And depending on the query, we may want to keep these values as such. I also would like to avoid adding our own custom "cast" functions when cast functions already exist in SQL. I definitely feel like that's a red flag that we're not doing something quite right. So I have a proposal that I think addresses this well but does so very differently. In the |
| session.transfer(original, REL_FAILURE); | ||
| } catch (final Exception e) { | ||
| getLogger().error("Unable to query {} due to {}", new Object[] {original, e}); | ||
| getLogger().error("Unable to query {} due to {}", new Object[] {original, e.getCause() == null ? e : e.getCause()}); |
There was a problem hiding this comment.
I don't think we want to be getting the 'cause' for the general Exception - we should log the exception itself. We get the cause for SQLException only because we know that it's generally wrapping another exception.
There was a problem hiding this comment.
Yeah, this one was a strange one. Since the calcite cast function throwing the cannot handle Object exception was getting trapped here and the message was super vague so had to dig into the app logs to see the stack trace.
There was a problem hiding this comment.
Yeah unfortunately for this processor, when an Exception is thrown it's kind of difficult to figure out without the logs. But if we were to unwrap the cause, that could make even the logs confusing, which is even worse.
|
@pcgrenier I created a new PR based off of yours - #4282. Can you review that and make sure that it gives you what you need? This will allow the table schema to be more intelligent for CHOICE types and in cases like this it will allow you to use proper SQL CAST functions and also allows you to perform functions like SUM() without the need to explicitly cast them, which is important if your data does have mixed data types. |
|
Closing in favor of #4282 |
QueryRecord cast functions for Choice datatypes
Thank you for submitting a contribution to Apache NiFi.
Please provide a short description of the PR here:
Description of PR
Enables X functionality; fixes bug NIFI-YYYY.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
master)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squashor use--forcewhen pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean installat the rootnififolder?LICENSEfile, including the mainLICENSEfile undernifi-assembly?NOTICEfile, including the mainNOTICEfile found undernifi-assembly?.displayNamein addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.