[PLAT-435] allow dict rewrites in ch without create temp table privileges, add docs#9020
[PLAT-435] allow dict rewrites in ch without create temp table privileges, add docs#9020
Conversation
| switch d { | ||
| case DialectClickHouse: | ||
| return fmt.Sprintf("SELECT %s FROM dictionary(%s)", d.EscapeIdentifier(lookupKeyColumn), d.EscapeIdentifier(lookupTable)), nil | ||
| return fmt.Sprintf("SELECT %s FROM %s", d.EscapeIdentifier(lookupKeyColumn), d.EscapeQualifiedIdentifier(lookupTable)), nil |
There was a problem hiding this comment.
now this directly reads from the dictionary table, may be we should make this configurable if the dictionary table as dictionary() may directly read from memory if the dict is loaded in memory so a minor optimization probably.
There was a problem hiding this comment.
I'm not sure I understand this issue, why can't we keep dictionary(%s)? And how would you propose to make it configurable?
There was a problem hiding this comment.
using dictionary() is the main issue for which PR is raised, its a table function and on the table functions page it says You can't use table functions if the [allow_ddl](https://clickhouse.com/docs/operations/settings/settings#allow_ddl) setting is disabled. Customer queries are failing with
Not enough privileges. To execute this query, it's necessary to have the grant CREATE TEMPORARY TABLE ON *.*. (ACCESS_DENIED)
Thus directly reading from the underlying dictionary table. By making it configurable I meant using an instance config flag using which we will choose if to use table function or directly read from dict table.
There was a problem hiding this comment.
Would be nice to avoid a config flag for such an edge case if possible. But it's okay if it's needed.
Does dictionary() impact performance a lot? If it does, then maybe we should just tell users that Clickhouse requires DDL access to use dictionaries in Rill? If it doesn't, then I think this is fine and we can just not use the table func.
There was a problem hiding this comment.
Don't have empirical evidence around performance as in practice dictionary tables are really small so could not see much difference. I think its fine to keep this not configurable.
| switch d { | ||
| case DialectClickHouse: | ||
| return fmt.Sprintf("SELECT %s FROM dictionary(%s)", d.EscapeIdentifier(lookupKeyColumn), d.EscapeIdentifier(lookupTable)), nil | ||
| return fmt.Sprintf("SELECT %s FROM %s", d.EscapeIdentifier(lookupKeyColumn), d.EscapeQualifiedIdentifier(lookupTable)), nil |
There was a problem hiding this comment.
Instead of automatically parsing dots in lookup_table, should we add an optional lookup_database property since clickhouse table names can have dots in them. Since its very rare and may also require quoting full table name while doing dictGet, I just kept it simple.
There was a problem hiding this comment.
I think it's fine to keep it simple – see my other comment
| switch d { | ||
| case DialectClickHouse: | ||
| return fmt.Sprintf("SELECT %s FROM dictionary(%s)", d.EscapeIdentifier(lookupKeyColumn), d.EscapeIdentifier(lookupTable)), nil | ||
| return fmt.Sprintf("SELECT %s FROM %s", d.EscapeIdentifier(lookupKeyColumn), d.EscapeQualifiedIdentifier(lookupTable)), nil |
There was a problem hiding this comment.
I think it's fine to keep it simple – see my other comment
| switch d { | ||
| case DialectClickHouse: | ||
| return fmt.Sprintf("SELECT %s FROM dictionary(%s)", d.EscapeIdentifier(lookupKeyColumn), d.EscapeIdentifier(lookupTable)), nil | ||
| return fmt.Sprintf("SELECT %s FROM %s", d.EscapeIdentifier(lookupKeyColumn), d.EscapeQualifiedIdentifier(lookupTable)), nil |
There was a problem hiding this comment.
I'm not sure I understand this issue, why can't we keep dictionary(%s)? And how would you propose to make it configurable?
EscapeQualifiedIdentifierto escape dot-separated identifiers (e.g.db.table) which may be provided forlookup_tableproperty.LookupSelectExprto query the dictionary table directly instead of usingdictionary()table function, which requiresCREATE TEMPORARY TABLEprivilege.Checklist: