Skip to content
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

Table sources, support WHERE conditions #1605

Open
artyomb opened this issue Dec 5, 2024 · 2 comments
Open

Table sources, support WHERE conditions #1605

artyomb opened this issue Dec 5, 2024 · 2 comments
Labels
config Relates to Martin configuration enhancement help wanted pg Related to PostgreSQL sources

Comments

@artyomb
Copy link

artyomb commented Dec 5, 2024

That would be very useful to have "where" in table sources:

  tables:
    tab_filtered:
      layer_id: table_source

      # Table name (required)
      table: table_source
      
      # SQL where conditions
      where: (TYPE = 'A') and (Pop > 100)
@artyomb
Copy link
Author

artyomb commented Dec 11, 2024

Even better I guess:

  tables:
    tab_filtered:
      layer_id: table_source
      table_sql: SELECT * FROM table WHERE ...

@nyurik
Copy link
Member

nyurik commented Dec 11, 2024

There has been some conversations about this type of capability. Fundamentally there is nothing stopping us from doing this, with the possible exception that this, by definition, is a subset of functionality already available with SQL functions - so we need to clearly understand why we want to duplicate it... that said, this is indeed simpler than writing a full sql function. This also requires some somewhat unsafe SQL manipulation, but nothing too dangerous - i.e. config author can now write DROP TABLE in that statement, but i guess we have to trust config file.

I don't think we want the second table_sql variant, as it creates more problems -- we would need to evaluate the statement, see which columns are returned, check that exactly one of them is a gis column, match it up with the rest of the table configuration, ... - not worth it. Adding where config value on the other hand seems like a good path.

In short - PRs welcome, should be fairly simple to add.

@nyurik nyurik added enhancement help wanted config Relates to Martin configuration pg Related to PostgreSQL sources labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Relates to Martin configuration enhancement help wanted pg Related to PostgreSQL sources
Projects
None yet
Development

No branches or pull requests

2 participants