Hi, is there a dialect file for starrocks? I am us...
# questions-and-troubleshooting
h
Hi, is there a dialect file for starrocks? I am using Sisense BI to query from starrocks however I am getting parsing errors. Sisense allows uploading custom dialects and JDBC connectors. Can anyone help me with this please?
е
anyway it should be mysql dialect othervise
h
AFAIK, starrocks only supports mysql/trino dialects. I’m unsure where to go from here because i’ve tried various JDBC connectors/versions from sisense which produce syntactically equivalent SQL queries, which starrocks cannot parse.
I would have thought there’s some sort of dialect file native to starrocks which I can upload to sisense but I guess not.
е
what are the errors you are seeing?
h
Copy code
ERROR 1064 (HY000): Getting syntax error at line 11, column 29. Detail message: No viable statement for input 'CAST(
    CAST(
      CAST(
        PERCENTILE_DISC(0.5) WITHIN'.
theres an issue with translation of percentile formulas. E.g
PERCENTILE([carrier_transit_duration], 0.5)
which translates to the following sql query on sisense side:
Copy code
WITH `xyz_tq_20FWEUlzE` AS (
  SELECT
    *
  FROM
    `some_db`.`some_table`
)
SELECT
  CAST(
    CAST(
      CAST(
        PERCENTILE_DISC(0.5) WITHIN GROUP (
          ORDER BY
            `carrier_transit_duration`
        ) AS DECIMAL(20, 6)
      ) / 60 AS DECIMAL(20, 6)
    ) / 60 AS DECIMAL(20, 6)
  ) / 24 AS `percentile__carrier_transit_duration__div__const_60__div__const_60__div__const_24_res`
FROM
  (
    SELECT
      `carrier_transit_duration`
    FROM
      `xyz_tq_20FWEUlzE` AS `tq_20FWEUlzE`
    WHERE
      `company_id` IN (
        SELECT
          `company_id`
        FROM
          (
            SELECT
              `company_id`
            FROM
              `somedb`.`some_dimension`
          ) AS `t`
        WHERE
          `company_id` = 1234
      )
  ) AS `t4`
i believe the starrocks syntax for percentiles is different like:
Copy code
PERCENTILE_DISC (expr, percentile)
i tried using various jdbc connectors, as sisense suggested, to see if the generated query is different among different connectors. They all yielded the same problematic query. The suggestion from sisense is now to try custom dialect files.
е
when i wanted to google more info about custom dialect files, i only found this https://community.sisense.com/discussions/help_and_how_to/generic-jdbc-clickhouse-live-model-with-custom-dialect/22025 which seems like “dont do it yourselves, contact support”
h
Sisense support cannot assist further. They have given the options of using custom connectors and/or custom dialect files.
е
i cant find any docs on what are these and how to transform PERCENTILE_DISC to what starrocks excepcts
h
Me neither. I have never come across dialect files that can be uploaded, which a JDBC connector then uses. That's what Sisense is offering. https://github.com/StarRocks/starrocks/blob/af49488e6f86ec5d68fd3e8104825ed5bc504e5e/contrib/starrocks-python-client/starrocks/dialect.py#L4 Maybe I need a java equivalent of the above?
and of course there is the apache calcite starrocks dialect file that's mentioned in the thread you linked earlier https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java However i see no conversion of Percentile in the source code within the above link
е
here is what deepseek gives me
starrocks_percentile_fix.json
Copy code
{
  "name": "StarRocks_Percentile_Fix",
  "basedOn": "mysql",
  "functions": {
    "percentile": {  
      "format": "PERCENTILE_DISC({args[0]}, {args[1]})",  // column, percentile
      "argumentCount": 2
    }
  },
  "identifierQuote": "`",
  "literalQuote": "'"
}
go to Admin → Data → SQL Dialects and try it
maybe you should tackle it with sisense support as they are more qualified with this
👍 1
h
I don't see any Data section in Admin console on Sisense. The only place I see concerning dialects is in the connectors page, where you can upload a dialect (.java) file against a connector.
е
ok, so it was complete hallucination from deepseek
h
yup thank you for all your input so far @Евгений Шишкин
I am unsure what is generating the dirty SQL query/translation in Sisense. Sisense suggests it's the connector. But different connectors have yielded the same query.
е
do you have access to its clickhouse connector source?
it might be a good example
click is also very function heavy sql
h