Comments (5)
I checked the behavior in Postgres and found it doing casting implicitly, maybe the idea of Signature::Equal is not suitable for nullif. 😢
create table t1 (a int);
postgres=# select pg_typeof(nullif(a, 3.1)) from t1;
pg_typeof
-----------
numeric
numeric
numeric
numeric
numeric
(5 rows)
postgres=# select pg_typeof(nullif(a, '2')) from t1;
pg_typeof
-----------
integer
integer
integer
integer
integer
(5 rows)
postgres=# select pg_typeof(nullif(a, 2)) from t1;
pg_typeof
-----------
integer
integer
integer
integer
integer
(5 rows)
from arrow-datafusion.
I think the coercion logic here is similar to coalesce and array. #10261 (comment)
from arrow-datafusion.
I think this would not need a lot of changes and I want to take it. :)
from arrow-datafusion.
After a initial try, there is an issue shown below:
statement ok
CREATE TABLE test(
int_field INT,
bool_field BOOLEAN,
text_field TEXT,
more_ints INT
) as VALUES
(1, true, 'abc', 2),
(2, false, 'def', 2),
(3, NULL, 'ghij', 3),
(NULL, NULL, NULL, 4),
(4, false, 'zxc', 5),
(NULL, true, NULL, 6)
;query I rowsort
SELECT NULLIF(int_field, 2) FROM test;
External error: query failed: DataFusion error: Error during planning: No function matches the given name and argument types 'nvl(Int32, Int64)'. You might need to add explicit type casts.
I think it's because the first type is INT(32), however datafusion will treat the const 2 as int64.🤔
I will also see whether there is a solution.
Edit:
I think adding CAST would resolve this, would it be a good way?
SELECT NULLIF(int_field, CAST(2 as INT)) FROM test;
from arrow-datafusion.
Got it, it seems that datafusion can't do casting implicitly now, so the idea may be not available now. 👀
from arrow-datafusion.
Related Issues (20)
- Stop copying LogicalPlan and Exprs in `SingleDistinctToGroupBy` HOT 4
- Stop copying LogicalPlan and Exprs in `EliminateNestedUnion` HOT 1
- Enable bloom filters by default on read HOT 5
- Create fixed size list table with syntax <type name>[<length>] HOT 6
- Using `date_bin` with a time zone in a time range that contains daylight savings does not work HOT 3
- binary_op should be handled by sql_expr_to_logical_expr.. This was likely caused by a bug in DataFusion's code HOT 4
- [Epic] A Collection of Sort Based Optimizations HOT 5
- Implement a way to preserve partitioning through `UnionExec` without losing ordering
- DataFusion should support casting strings such as "4e7" to decimal HOT 2
- Optimized version of `SortPreservingMerge` that doesn't actually compare sort keys of the key ranges are ordered HOT 15
- Regression with `coalesce` expr_fn function: can't take multiple arguments
- INSERT INTO SQL failing on CSV-backed table HOT 3
- Unify SQL planning for `ORDER BY`, `HAVING`, `DISTINCT`, etc
- Unable to perform lead/lag built in functions on List and Struct data types HOT 1
- Enable `split_file_groups_by_statistics` by default HOT 3
- Avoid inlining non deterministic CTE HOT 2
- Make all SchemaProvider trait APIs async HOT 4
- Document timezone semantics HOT 2
- Schema incorrect after select over aggregate function that returns a different type than the input HOT 5
- clippy failure in main HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrow-datafusion.