Skip to content

Conversation

@61yao
Copy link
Contributor

@61yao 61yao commented Mar 3, 2023

Support null literal in broker logic for selection only query.

Scalar functions are categorized as null tolerant vs intolerant.

intolerant scalar functions return null when any of the arg is null.

Introduce null columnDataType as passing used to pass broker response back to user.

@61yao 61yao changed the title [feature] [null support] selection only literal in broker null support [feature] [null support # 1] selection only literal in broker null support Mar 3, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2023

Codecov Report

Merging #10376 (9a8ace5) into master (8bfb0b8) will increase coverage by 50.12%.
The diff coverage is 46.66%.

@@              Coverage Diff              @@
##             master   #10376       +/-   ##
=============================================
+ Coverage     13.97%   64.09%   +50.12%     
- Complexity      237     6090     +5853     
=============================================
  Files          2016     2016               
  Lines        109575   109491       -84     
  Branches      16778    16759       -19     
=============================================
+ Hits          15315    70181    +54866     
+ Misses        93012    34172    -58840     
- Partials       1248     5138     +3890     
Flag Coverage Δ
unittests1 67.87% <51.85%> (?)
unittests2 13.98% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...roker/requesthandler/BaseBrokerRequestHandler.java 46.62% <0.00%> (-0.16%) ⬇️
...ot/common/request/context/RequestContextUtils.java 65.14% <0.00%> (+65.14%) ⬆️
...pache/pinot/common/utils/request/RequestUtils.java 67.52% <0.00%> (+67.52%) ⬆️
.../parsers/rewriter/CompileTimeFunctionsInvoker.java 95.55% <50.00%> (+95.55%) ⬆️
.../apache/pinot/common/function/FunctionInvoker.java 87.50% <60.00%> (+87.50%) ⬆️
...java/org/apache/pinot/common/utils/DataSchema.java 76.89% <100.00%> (+76.89%) ⬆️
.../pinot/core/common/datablock/DataBlockBuilder.java 77.86% <100.00%> (+77.86%) ⬆️
...main/java/org/apache/pinot/spi/data/FieldSpec.java 82.07% <100.00%> (+82.07%) ⬆️

... and 1348 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. 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.

If false -> if true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Updated the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Object) value -> (Object) null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value should already be null here. but yeah, it is more clear we pas in a null. updated the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can avoid branching here and simply return "null"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

There are like one thousand places where FieldSpec.DataType, which is specially problematic in switch. Here the datatype I proposed in #10361 may be useful, but we decided to drop it.

Have you checked the impact of this new literal in these switch? Or do you plan to do that in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. this PR just adds the interface needed and handles the broker logic.
Adding an extra type makes sure the code will error out when there is an error. instead of using some existing type to hide the error.

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is that this PR does add UNKNOWN literal into FieldSpec.DataType, but doesn't changes any of the places where FieldSpec.DataType was used. This is specially important on switches. If they include a default case, the new literal will fall on that case, which will usually throw exceptions. In case of switchs without default case it can even be worse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. I''ll add the handling later since null literal isn't supported today anyway

@gortiz
Copy link
Contributor

gortiz commented Mar 21, 2023

Can some contributor approve the workflow please? Otherwise we cannot see the result of the tests.

Copy link
Contributor

@gortiz gortiz 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

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

return expression;
}

public static Expression getUnknownLiteralExpression() {
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor)

Suggested change
public static Expression getUnknownLiteralExpression() {
public static Expression getNullLiteralExpression() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

for (int i = 0; i < numOperands; i++) {
arguments[i] = function.getOperands().get(i).getLiteral().getFieldValue();
Literal literal = function.getOperands().get(i).getLiteral();
if (literal.getSetField() == Literal._Fields.NULL_VALUE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor)

Suggested change
if (literal.getSetField() == Literal._Fields.NULL_VALUE) {
if (literal.isSetNullValue) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

OBJECTS[rowId] = isNull ? null : RANDOM.nextDouble();
dataTableBuilder.setColumn(colId, OBJECTS[rowId]);
break;
case UNKNOWN:
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) Move it to the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Assert.assertEquals(ObjectSerDeUtils.deserialize(customObject), OBJECTS[rowId], ERROR_MESSAGE);
}
break;
case UNKNOWN:
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) Move it to the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 750 to 751
Object nulValue = newDataTable.getCustomObject(rowId, colId);
Assert.assertNull(nulValue, ERROR_MESSAGE);
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit)

Suggested change
Object nulValue = newDataTable.getCustomObject(rowId, colId);
Assert.assertNull(nulValue, ERROR_MESSAGE);
Assert.assertNull(newDataTable.getCustomObject(rowId, colId), ERROR_MESSAGE);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mayankshriv mayankshriv merged commit d1227e4 into apache:master Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants