Git Product home page Git Product logo

Comments (2)

max-sixty avatar max-sixty commented on June 21, 2024

Good example and it's encouraging to see you pushing functions like this!

There are definitely a few things up — it obv shouldn't panic there.

Also putting an s-string within the pipeline panics :(

let coalesce_bool = func
  val <scalar || null>
  -> case [
    (s"{val}" | in ["no", "n", "N", "false"]) => false,
  ]

from [{foo = 1}, {foo = null}]
derive { foo_b = coalesce_bool foo }

For completeness — if I put this in the playground, duckdb doesn't raise an error — does it on your end? Is the error message because of the type of some data that's not there?

let coalesce_bool = func
  val <scalar || null>
  -> case [
    val == null => null,
    val == 0 => false,
    val == 1 => true,
    (val | in ["no", "n", "N", "false"]) => false,
    (val | in ["yes", "y", "Y", "true"]) => true,
  ]

from [{foo = 1}, {foo = null}]
derive { foo_b = coalesce_bool foo }

For a workaround — does an s-string in another transform suffice for the moment?

from [{ a = 1 }]
derive a_ = (s"{a} as VARCHAR")
derive { b = ( a_ | in [2, 3] ) }

from prql.

kgutwin avatar kgutwin commented on June 21, 2024

I have to run now, but quickly -- I can provide some more details later on how I've managed to trigger the underlying situation, but unfortunately an s-string in another transform isn't a great solution because of the way this function is used in other parts of our PRQL.

I'm hoping that the PR that I threw together is a simple solution; it does fix the s-string panic as well.

from prql.

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.