Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill, mail # dev - How to contribute ?


Copy link to this message
-
Re: How to contribute ?
Julian Hyde 2013-12-09, 18:35
As for the code-generation, you might like to leverage the implementation in Optiq:

  /** SQL {@code LIKE} function. */
  public static boolean like(String s, String pattern) {
    final String regex = Like.sqlToRegexLike(pattern, null);
    return Pattern.matches(regex, s);
  }

  /** SQL {@code LIKE} function with escape. */
  public static boolean like(String s, String pattern, String escape) {
    final String regex = Like.sqlToRegexLike(pattern, escape);
    return Pattern.matches(regex, s);
  }

  /** SQL {@code SIMILAR} function. */
  public static boolean similar(String s, String pattern) {
    final String regex = Like.sqlToRegexSimilar(pattern, null);
    return Pattern.matches(regex, s);
  }

  /** SQL {@code SIMILAR} function with escape. */
  public static boolean similar(String s, String pattern, String escape) {
    final String regex = Like.sqlToRegexSimilar(pattern, escape);
    return Pattern.matches(regex, s);
  }

and see https://github.com/julianhyde/optiq/blob/master/core/src/main/java/net/hydromatic/optiq/runtime/Like.java.

This can be packaged up as a DrillFunc.

However, fixing DrillOptiq$RexToDrill.visitCall is more challenging.

Julian
On Dec 6, 2013, at 1:50 PM, Jinfeng Ni <[EMAIL PROTECTED]> wrote:

> I believe we do not have support for like predicate. You may try some
> simple comparison predicate, eg. =, >, etc.
>
>
> On Fri, Dec 6, 2013 at 1:22 PM, Norris Lee <[EMAIL PROTECTED]> wrote:
>
>> Hello,
>>
>> I took a stab at trying to implement the "like" function by adding to
>> org/apache/drill/common/expression/fn/BooleanFunctions.java and
>> org/apache/drill/exec/expr/fn/impl/ComparisonFunctionsNullable.java (Are
>> these the right files to add it to?). However, I hit an error with
>> DrillOptiq. The error I got was:
>>
>> 0: jdbc:drill:schema=parquet-local> select * from
>> "sample-data/region.parquet" where 'test' like 'test';
>> java.lang.AssertionError: todo: implement syntax Special(LIKE('test',
>> 'test'))
>>        at
>> org.apache.drill.optiq.DrillOptiq$RexToDrill.visitCall(DrillOptiq.java:129)
>>        at
>> org.apache.drill.optiq.DrillOptiq$RexToDrill.visitCall(DrillOptiq.java:75)
>>        at org.eigenbase.rex.RexCall.accept(RexCall.java:220)
>>        at org.apache.drill.optiq.DrillOptiq.toDrill(DrillOptiq.java:71)
>>        at
>> org.apache.drill.optiq.DrillFilterRel.implement(DrillFilterRel.java:57)
>>        at
>> org.apache.drill.optiq.DrillImplementor.go(DrillImplementor.java:99)
>>        at
>> org.apache.drill.optiq.EnumerableDrillRel.implement(EnumerableDrillRel.java:108)
>>        at
>> net.hydromatic.optiq.rules.java.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:69)
>>        at
>> net.hydromatic.optiq.prepare.OptiqPrepareImpl$OptiqPreparingStmt.implement(OptiqPrepareImpl.java:541)
>>        at
>> net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:227)
>>        at
>> net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:131)
>>        at
>> net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:256)
>>        at
>> net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare_(OptiqPrepareImpl.java:196)
>>        at
>> net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepareSql(OptiqPrepareImpl.java:169)
>>        at
>> net.hydromatic.optiq.jdbc.OptiqStatement.parseQuery(OptiqStatement.java:402)
>>        at
>> net.hydromatic.optiq.jdbc.OptiqStatement.execute(OptiqStatement.java:192)
>>        at sqlline.SqlLine$Commands.execute(SqlLine.java:3825)
>>        at sqlline.SqlLine$Commands.sql(SqlLine.java:3738)
>>        at sqlline.SqlLine.dispatch(SqlLine.java:882)
>>        at sqlline.SqlLine.begin(SqlLine.java:717)
>>        at sqlline.SqlLine.mainWithInputRedirection(SqlLine.java:460)
>>        at sqlline.SqlLine.main(SqlLine.java:443)
>>
>> How would I go on from there? Any help/suggestions would be appreciated.
>> (I will create a JIRA for this soon).
>>
>> Thanks,
>> Norris
>>
>> -----Original Message-