ddavisqa / google-refine

Automatically exported from code.google.com/p/google-refine
0 stars 0 forks source link

Cannot create filter based on boolean expression #309

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a facet on numerical column.
2. Choose GREL as language and enter boolean expression like "value > 0 && 
value < 0.5"
At this point in the preview pop-up I see correct "true" and "false" values.
3. Press OK

Now the pop-up goes away as expected, and on the "Facet/Filter" pane on the 
left I see my new facet, but the formula is wrong:

      clojure:value > 0 && value < 0.5

Under that I see an error:
       java.lang.Exception: Unable to resolve symbol: && in this context (NO_SOURCE_FILE:1)

So the problem is, it chooses "clojure" as language no matter what I say. 

Using Google Refine 2.0 .

Running server on Linux : Red Hat Enterprise Linux ES release 4 (Nahant Update 
8)

Client browser on Windows 7 64-bit, either Opera or Firefox, both show the same 
problem.

I wonder if there is any workaround I can use while you are fixing this.

Thanks,

Leonid Ilyevsky

Original issue reported on code.google.com by lilyev...@gmail.com on 18 Jan 2011 at 6:24

GoogleCodeExporter commented 8 years ago
Can you please retest with the Refine 2.1 RC1 release candidate?  I can't 
reproduce the error there.  A custom text facet works with your expression, 
while a custom numeric facet gives an error for non-numeric values (since it's 
a boolean expression).

Original comment by tfmorris on 14 Jun 2011 at 7:36

GoogleCodeExporter commented 8 years ago
I think this is a misunderstanding about a numeric facet. The expression value 
> 0 && value < 0.5 is not a number, it's a true/false value so it's not able to 
be (directly) mapped onto a number scale for plotting a histogram. As Tom says, 
for a boolean expression a Text Facet (aka list facet) is needed.

You *can* make a custom numeric facet by doing something like, if(value > 0 && 
value < 0.5, 1, 0)

Original comment by paulm%pa...@gtempaccount.com on 14 Jun 2011 at 7:44

GoogleCodeExporter commented 8 years ago
> You *can* make a custom numeric facet by doing something like, if(value > 0 
&& value < 0.5, 1, 0)

I spoke too soon - apparently this doesn't work; "Parsing error at offset 13: 
Missing )". David?

(If you want to see what it looks like at least select Jython and,
return 1 if value > 0 and value < 0.5 else 0
I tested this this time :-))

Original comment by paulm%pa...@gtempaccount.com on 14 Jun 2011 at 8:56

GoogleCodeExporter commented 8 years ago
I don't know whether this was fixed after the original report or was just a 
misunderstanding, but either way I'm satisfied that the current implementation 
provides this functionality, so I'm closing this out.

p.s. Paul's numeric facet proposal can be modified as follows to work:

    if(and(value > 0,value < 0.5), 1, 0)

Original comment by tfmorris on 14 Oct 2011 at 8:53