google / zetasql

ZetaSQL - Analyzer Framework for SQL
Apache License 2.0
2.28k stars 214 forks source link

Create simple catalog takes a long time #149

Open milley23 opened 1 year ago

milley23 commented 1 year ago

Hi, sorry for asking here. I am using zetasql in my Java Springboot application. When I hit my endpoint that is integrated to zetasql, the duration time is very slow. I checked using newrelic and found that this function need about 9-10s to complete. It affects my endpoint duration time, so I want to optimize it. But, I have any idea how to optimize it. Could anyone please help ? Thank you.

public static SimpleCatalog createEmptyCatalog() {
    SimpleCatalog catalog = new SimpleCatalog("catalog");

    // Add built-in functions
    catalog.addZetaSQLFunctions(new ZetaSQLBuiltinFunctionOptions());

    // Add BigQuery-specific type aliases
    catalog.addType("INT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
    catalog.addType("SMALLINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
    catalog.addType("INTEGER", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
    catalog.addType("BIGINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
    catalog.addType("TINYINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
    catalog.addType("BYTEINT", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_INT64));
    catalog.addType("DECIMAL", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_NUMERIC));
    catalog.addType(
        "BIGDECIMAL", TypeFactory.createSimpleType(ZetaSQLType.TypeKind.TYPE_BIGNUMERIC));

    return catalog;
  }