calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Bateman <m...@lycono.com>
Subject CharSequence comparison
Date Tue, 08 Dec 2015 14:22:12 GMT
Hi,

I have a row type object that has a CharSequence member called "name". It
turns out I can't compare this with a "string" or character array in a SQL
statement.

For instance: "SELECT * FROM <table> WHERE name = 'FOO'"

complains

Cannot apply '=' to arguments of type '<JAVATYPE(INTERFACE
JAVA.LANG.CHARSEQUENCE)> = <CHAR(3)>'. Supported form(s):
'<COMPARABLE_TYPE> = <COMPARABLE_TYPE>'

I think I get the issue, that CharSequence does not implement "Comparable".
So I'm out of luck there.

Then I figured I could create a function to convert a CharSequence into a
character array or a string.

So I have this:

import org.apache.calcite.linq4j.function.Function1;

public class CharSequenceToCharArrayFunction implements
Function1<CharSequence, char[]> {

    public CharSequenceToCharArrayFunction() {
        System.out.println("Instantiated");
    }

    @Override
    public char[] apply(CharSequence str) {
        return str.toString().toCharArray();
    }

}

However, when I try it complains:

No match found for function signature seqToChar(<JavaType(interface
java.lang.CharSequence)>)

My schema definition:

{
"version": "1.0",
"defaultSchema": "USERS",
"schemas":
    [
        {
            "name": "USERS",
            "type": "custom",
            "factory": "com.foo.calcite.CStoreSchemaFactory",
            "operand":
            {
                "directory": "/tmp"
            },

            "functions":
            [
                {
                    "name": "seqToChar",
                    "className":
"com.foo.calcite.CharSequenceToCharArrayFunction",
                    "methodName": "apply"
                }
            ]
        }
    ]
}

Any insight?

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