Git Product home page Git Product logo

Comments (5)

jayzhan211 avatar jayzhan211 commented on June 5, 2024 1

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.

jayzhan211 avatar jayzhan211 commented on June 5, 2024 1

I think the coercion logic here is similar to coalesce and array. #10261 (comment)

from arrow-datafusion.

yyy1000 avatar yyy1000 commented on June 5, 2024

I think this would not need a lot of changes and I want to take it. :)

from arrow-datafusion.

yyy1000 avatar yyy1000 commented on June 5, 2024

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.

yyy1000 avatar yyy1000 commented on June 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.