Aircloak / aircloak

This repository contains the Aircloak Air frontend as well as the code for our Cloak query and anonymization platform
2 stars 0 forks source link

[SUP-69] Invalid column of analyst table is being queried #4616

Closed edongashi closed 4 years ago

edongashi commented 4 years ago

https://aircloak.atlassian.net/browse/SUP-69

When doing this query

select count(contract_id), Month
from TMP_FK_USAGE_DATA_JAN
group by Month

it fails with

"TMP_FK_USAGE_DATA_JAN"."_ac_nlc_16": invalid identifier

whereas the analyst table only has

CREATE TABLE AIRCLOAK."__ac_VnccnG6rT+z922Xmw97a1E2aX"
(
CONTRACT_ID     NUMBER                        NOT NULL,
"sum"           NUMBER,
"Pack"          CHAR(1 BYTE),
"month"         DATE,
"_ac_nlc_1"   DATE,
"_ac_nlc_2"   DATE,
"_ac_nlc_3"   NUMBER,
"_ac_nlc_4"   NUMBER,
"_ac_nlc_5"   NUMBER,
"_ac_nlc_6"   NUMBER,
"_ac_nlc_7"   NUMBER,
"_ac_nlc_8"   NUMBER,
"_ac_nlc_9"   NUMBER,
"_ac_nlc_10"  NUMBER,
"_ac_nlc_11"  DATE,
"_ac_nlc_12"  DATE,
"_ac_nlc_13"  DATE,
"_ac_nlc_14"  DATE
)
edongashi commented 4 years ago

Minimal reproduction:

select count(*)
from my_table

Fails with

ERROR 42703 (undefined_column) column my_table.__ac_nlc__1 does not exist

query: SELECT "__ac_regular_stats"."__ac_count_duid","__ac_regular_stats"."__ac_agg_0_count","__ac_regular_stats"."__ac_agg_0_sum","__ac_regular_stats"."__ac_agg_0_min","__ac_regular_stats"."__ac_agg_0_max","__ac_regular_stats"."__ac_agg_0_stddev","__ac_regular_stats"."__ac_grouping_id","__ac_regular_stats"."__ac_min_uid","__ac_regular_stats"."__ac_max_uid","__ac_regular_stats"."__ac_nlc__0" AS "__ac_nlc__0","__ac_regular_stats"."__ac_nlc__1" AS "__ac_nlc__1" FROM (SELECT "__ac_uid_grouping"."__ac_grouping_id" AS "__ac_grouping_id",COUNT("__ac_uid_grouping"."uid") AS "__ac_count_duid",MIN("__ac_uid_grouping"."uid") AS "__ac_min_uid",MAX("__ac_uid_grouping"."uid") AS "__ac_max_uid",COUNT("__ac_uid_grouping"."__ac_agg_0") AS "__ac_agg_0_count",SUM("__ac_uid_grouping"."__ac_agg_0") AS "__ac_agg_0_sum",MIN("__ac_uid_grouping"."__ac_agg_0") AS "__ac_agg_0_min",MAX("__ac_uid_grouping"."__ac_agg_0") AS "__ac_agg_0_max",STDDEV("__ac_uid_grouping"."__ac_agg_0") AS "__ac_agg_0_stddev",MIN("__ac_uid_grouping"."__ac_nlc__0") AS "__ac_nlc__0",MAX("__ac_uid_grouping"."__ac_nlc__1") AS "__ac_nlc__1" FROM (SELECT "my_table"."uid" AS "uid",COUNT(*) AS "__ac_agg_0",0 AS "__ac_grouping_id",MIN("my_table"."__ac_nlc__0") AS "__ac_nlc__0",MAX("my_table"."__ac_nlc__1") AS "__ac_nlc__1" FROM "__ac_4TMoutZmn1BRr89fXhHXU/vAR" AS "my_table" WHERE "my_table"."uid" IS NOT NULL GROUP BY "my_table"."uid") AS "__ac_uid_grouping" GROUP BY "__ac_uid_grouping"."__ac_grouping_id") AS "__ac_regular_stats"

hint: Perhaps you meant to reference the column "my_table.__ac_nlc__0".

my_table definition:

SELECT uid, max(age) as oldest FROM demographics
WHERE age BETWEEN 0 AND 10
GROUP BY uid

The cloak stores the analyst table like this:

   Column    |  Type   | Collation | Nullable | Default 
-------------+---------+-----------+----------+---------
 uid         | integer |           |          | 
 oldest      | integer |           |          | 
 __ac_nlc__0 | integer |           |          |