-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decide how to configure postgres table/function auto-discovery #512
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
We can use this format to have more granular control over public schemas, tables, and functions, and keep it less verbose # Expose schemas, tables, and functions automatically
auto_publish:
# Expose all tables and functions from the following schemas.
# Use "*" to expose all available sources.
# Extends the `from_schemas` lists in the `tables` and `functions` below
schemas: ["public", "my_schema"]
tables:
# Format string to build table source id.
id_format: "{schema}.{function}.{column}"
# Expose tables from the schemas list.
# Use "*" to expose all available tables.
from_schemas: ["public", "my_tables_schema"]
functions:
# Format string to build function source id
id_format: "{schema}.{function}.{column}"
# Expose functions from the schemas list.
# Use "*" to expose all available functions.
from_schemas: ["public", "my_functions_schema"] Case 1Expose all tables and functions from all schemas auto_publish:
schemas: "*"
tables:
id_format: "{schema}.{table}.{column}"
functions:
id_format: "{schema}.{function}.{column}" This is the same as auto_publish:
tables:
id_format: "{schema}.{table}.{column}"
from_schemas: "*"
functions:
id_format: "{schema}.{function}.{column}"
from_schemas: "*" Case 2Expose tables from all schemas auto_publish:
tables:
id_format: "{schema}.{table}.{column}"
from_schemas: "*" Case 3Expose functions from the "my-functions" schema auto_publish:
functions:
id_format: "{schema}.{function}.{column}"
from_schemas: ["my-functions"] Case 4Expose all tables and functions from the auto_publish:
schemas: ["public"]
tables:
id_format: "{schema}.{table}.{column}"
from_schemas: ["my-tables"]
functions:
id_format: "{schema}.{function}.{column}"
from_schemas: ["my-functions"] |
I like it. A few things:
|
|
The easiest path to solve it IMO is:
Here's the list of all variants that enable auto source discovery for tables. Functions is similar. auto_publish: true
---
auto_publish: {}
---
auto_publish:
tables: true
---
auto_publish:
tables: {}
---
# this is the weirdest one, but makes sense - if functions are explicitly off, than tables are implicitly on
auto_publish:
functions: false |
P.S. |
I prefer to avoid implicit auto-publish if it's possible. I'd expect Mixing booleans and objects are kinda weird, but
It would allow us to simplify the config a bit more: # Expose all tables and functions from all schemas
auto_publish: true
# Same as above
auto_publish:
tables: true
functions: true # Disable auto-publish (same as omitting the `auto_publish` key)
auto_publish: false # Only expose all tables from all schemas
auto_publish:
tables: true
# Same as above
auto_publish:
tables: true
functions: false # Only expose all functions from all schemas
auto_publish:
functions: true
auto_publish:
tables: false
functions: true # Expose all tables and functions from the "public" schema and
# additionally, expose tables from the "my-tables" schema
# and functions from the "my-functions" schema
auto_publish:
schemas: ["public"]
tables: ["my-tables"]
functions: ["my-functions"] # Only expose tables from the "my-tables" schema
# and functions from the "my-functions" schema
auto_publish:
tables: ["my-tables"]
functions: ["my-functions"] # Only expose tables from the "my-tables" schema
auto_publish:
tables: ["my-tables"] # Only expose functions from the "my-functions" schema
auto_publish:
functions: ["my-functions"] |
I like most of the above, except the list variant: auto_publish:
tables: ["my-tables"]
functions: ["my-functions"] I think it is non-obvious that ...
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_publish: Option<BoolOrObject<PgCfgPublish>>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PgCfgPublish {
pub from_schema: Option<OneOrMany<String>>,
pub tables: Option<BoolOrObject<PgCfgPublishType>>,
pub functions: Option<BoolOrObject<PgCfgPublishType>>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PgCfgPublishType {
pub from_schema: Option<OneOrMany<String>>,
pub id_format: Option<String>,
} Lastly, with the bool, the main issue i have is this scenario -- what does it mean? The best way here is to act on what the user "meant", not on the exact following of the internal logic. auto_publish:
from_schema: public
functions: false The user here clearly meant "allow all tables from the schema |
* NEW: support for maplibre#512 - pg table/function auto-discovery * can filter schemas * can use patterns like `{schema}.{table}.{column}` and `{schema}.{function}` * NEW: add `calc_bounds` bool flag to allow disabling of the bounds computation * reworked integration tests to use yaml
* NEW: support for maplibre#512 - pg table/function auto-discovery * can filter schemas * can use patterns like `{schema}.{table}.{column}` and `{schema}.{function}` * NEW: add `calc_bounds` bool flag to allow disabling of the bounds computation * reworked integration tests to use yaml
Okay, let's agree on "Bool = enable/disable, object = details" :) However, I'd still prefer the user to be explicit about exposing tables in the example below. So it'd be safer when the user commented out/removed auto_publish:
from_schema: public
functions: false |
I think that would be extremely confusing - if I gave that specific configuration, my expectation is that tables are enabled - otherwise we have a whole configuration section that has no affect - not a good approach. This case below is so rare and weird, I would not take it into account auto_publish:
from_schema: public
# tables: true
functions: false |
* NEW: support for #512 - pg table/function auto-discovery * can filter schemas * can use patterns like `{schema}.{table}.{column}` and `{schema}.{function}` * NEW: add `disable_bounds` bool flag to allow disabling of the bounds computation * reworked integration tests to use yaml
added in #546 |
The upcoming #511 allows multiple postgres connections. Also, the recently merged #510 adds support for per-schema filtering when automatically configuring table and function sources. Yet, we don't have a way to configure them yet.
Proposed schema:
This is how currently users can automatically configure all available tables and functions in all schemas:
With this config, users enable just one table as a src1 source, and disable auto-discovery
Need feedback
Beyond the above, we may want to configure the following scenarios:
Other configuration ideas
See the primary idea at the top. Most of these other ideas apply to both tables and functions, but for brevity only one is mentioned.
P.S. I also renamed
connection_string
intoconnection
(will support older format for backward compat too)The text was updated successfully, but these errors were encountered: