trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.49k stars 3.02k forks source link

[Pinot connector] Failing queries when having duplicated aggregation metrics #13345

Open jpohanka opened 2 years ago

jpohanka commented 2 years ago

Trino version: 389

Description:

Let's assume that we have a Pinot table tab and in this table, we have the following columns:

Consider the following query in Pinot:

SELECT
  SUM(some_quantity) AS tot_quantity1,
  SUM(some_quantity) AS tot_quantity2
FROM
  tab

The following is the same Pinot query as a passthrough query in Trino:

SELECT
  *
FROM
  pinot.default."
    SELECT
      SUM(some_quantity) AS tot_quantity1,
      SUM(some_quantity) AS tot_quantity2
    FROM
      tab
  "

The first query runs successfully and returns the correct results.

The second query fails and throws the following error:

Multiple entries with same key: sum(some_quantity)=io.trino.plugin.pinot.query.DynamicTableBuilder$PinotColumnNameAndTrinoType@66fef16 and sum(some_quantity)=io.trino.plugin.pinot.query.DynamicTableBuilder$PinotColumnNameAndTrinoType@4023dfc1

This happens in the case of simple, as well as complex aggregate expressions.

elonazoulay commented 2 years ago

Which version of trino and pinot are you using? This may be related to another issue but I will have to see if it applies to the versions you are using.

elonazoulay commented 2 years ago

Soon we will migrate to table functions which should fix this issue, I will verify that and update.

jpohanka commented 2 years ago

@elonazoulay We use Trino 389 and a 'pre-release' of Pinot 0.11.0. Thank you for your help!