drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacques Nadeau <jacques.dr...@gmail.com>
Subject Expressions in the Logical Plan
Date Wed, 14 Nov 2012 02:27:24 GMT
I've been working on blowing out some example logical plans.  Originally, I
was thinking that embedded expressions would be okay (see my previous
email).  As I work through it, I think that utilizing ssa-ish
representation makes more sense for the logical plan. An example of this
might be:

Original Expression:

left(regex("activity.cookie", "persistent=([^;]*)"), 3)

New Expression

[
  { fn: "def", ref: "activity.cookie"},
  { fn: "regex", val: "0", pattern: "persistent=([^;]*)"}
  { fn: "left", val: "1", length: "3" }
]

Everything becomes a function.  Even case statements.  For clarity, a
function can receive nested arguments.

CASE
  WHEN user.gender='male' THEN ":/"
  WHEN user.gender='female THEN ":)"
  WHEN user.gender is null THEN ":("
  ELSE ":o"
END

Becomes:

[
  { fn: "ref", ref: "user.gender"},
  { fn: "equals", val1: "0", val2: "male"}
  { fn: "equals", val1: "0", val2: "female"}
  { fn: "isnull", val1: "0"}
  { fn: "case", cases: [
    { condition: "1", output: ":/" },
    { condition: "2", output: ":)"},
    { condition: "3", output: ":("},
    { condition: "4", output: ":o"}
  ]}
]


Thoughts/Opinions?  To simplify, we could things like make single value
argument functions implicitly refer to the previous output if no input is
provided...

Jacques

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message