trilogy-data / pytrilogy

A Higher-Level, Composable SQL

Home Page:https://preqldata.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Anonymous concepts via function dot access

greenmtnboy opened this issue · comments

Problem Statement

We by default create functions at parse time for extremely common use cases - such as keys having an automatic .count method.

This lends itself to nice syntax, like

select
customer.creation_date, customer.id.count

However, it's not clear when these helpers would exist by default, and annoying when they don't.

Proposed Solution

Support accessing ANY function that takes a single argument through a dynamically resolved concept

So if a function called 'hash' was registered, then
customer.id.hash would automatically be valid.

This chain should be automatically recursive, so
customer.id.count.hash would be valid

There's a tradeoff here with overlapping with concepts that are named differently. To combat that, propose by default preventing the definition of a concept with a name that would overlap with an anonymous function derived concept.

So for example,

property customer.id.count <- '1'; would throw an error at parse time.

Alternatives Considered

A dedicated signal symbol, like '|' or '>', that would indicate when access was being pushed to a function

so for example

select customer.id>count
or select customer.id|count|hash

Additional Context

Please provide any other information that may be relevant.