-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query: when rewriting null semantics for comparisons with functions use function specific metadata to get better SQL #18555
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
providers-beware
type-enhancement
Milestone
Comments
This was referenced Nov 1, 2019
maumar
added a commit
that referenced
this issue
Jan 15, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: canBeNull - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
maumar
added a commit
that referenced
this issue
Jan 16, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: nullResultAllowed - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
maumar
added a commit
that referenced
this issue
Jan 16, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: nullResultAllowed - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
maumar
added
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
providers-beware
labels
Jan 16, 2020
maumar
added a commit
that referenced
this issue
Jan 22, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: nullResultAllowed - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
maumar
added a commit
that referenced
this issue
Jan 22, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: nullResultAllowed - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
maumar
added a commit
that referenced
this issue
Jan 22, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: nullResultAllowed - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
maumar
added a commit
that referenced
this issue
Jan 22, 2020
…with functions use function specific metadata to get better SQL When we need to compute whether a function is null, we often can just evaluate nullability of it's constituents (instance & arguments), e.g. SUBSTRING(stringProperty, 0, 5) == null -> stringProperty == null Adding metadata to SqlFunctionExpression: nullResultAllowed - indicates whether function can ever be null, instancePropagatesNullability - indicates whether function instance can be used to calculate nullability of the entire function argumentsPropagateNullability - array indicating which (if any) function arguments can be used to calculate nullability of the entire function If "canBeNull" is set to false we can instantly compute IsNull/IsNotNull of that function. Otherwise, we look at values of instancePropagatesNullability and argumentsPropagateNullability - if any of them are set to true, we use corresponding argument(s) to compute function nullability. If all of them are set to false we must fallback to the old method and evaluate nullability of the entire function.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
providers-beware
type-enhancement
Some functions can only be nullable if their arguments are nullable (e.g. ToUpper, SubString). This results in much simpler and faster SQL - by removing unnecessary function calls to determine if the values are null we can levarage indexes better.
Some functions (e.g. DATEDIFF) use some of the arguments to determine its nullability but not all of them.
Some functions (e.g. JSON_VALUE) can be null even when neither of its arguments are null.
We should add metadata for the built-in functions so we know how to deal with their nullability, as well as provide means for user defined functions to specify how they should behave
The text was updated successfully, but these errors were encountered: