Search in sources :

Example 1 with CastStrToGeoHashFunctionFactory

use of io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory in project questdb by bluestreak01.

the class FunctionParserTest method testGeoHashFunction.

@Test
public void testGeoHashFunction() throws SqlException {
    functions.add(new CastStrToGeoHashFunctionFactory());
    final GenericRecordMetadata metadata = new GenericRecordMetadata();
    metadata.add(new TableColumnMetadata("gh", 1, ColumnType.getGeoHashTypeWithBits(25)));
    FunctionParser functionParser = createFunctionParser();
    Record record = new Record() {

        @Override
        public long getLong(int col) {
            return 847187636514L;
        }

        @Override
        public int getGeoInt(int col) {
            return (int) getLong(col);
        }
    };
    Function function = parseFunction("cast('sp052w92' as geohash(5c))", metadata, functionParser);
    Assert.assertEquals(ColumnType.getGeoHashTypeWithBits(25), function.getType());
    Assert.assertEquals(25854114, function.getGeoInt(record));
}
Also used : Function(io.questdb.cairo.sql.Function) CastStrToGeoHashFunctionFactory(io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory) Record(io.questdb.cairo.sql.Record) Test(org.junit.Test)

Aggregations

Function (io.questdb.cairo.sql.Function)1 Record (io.questdb.cairo.sql.Record)1 CastStrToGeoHashFunctionFactory (io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory)1 Test (org.junit.Test)1