dolthub / doltpy

A Python API for Dolt
Apache License 2.0
55 stars 13 forks source link

support `as_of` parameter in `read_pandas_sql` #177

Open kretes opened 2 years ago

kretes commented 2 years ago

This is a feature request for adding as_of parameter to read_pandas_sql. This parameter is available in read_pandas for reading the whole table, but it would be nice to have the same in a generic sql-based method: https://github.com/dolthub/doltpy/blob/main/doltpy/cli/read.py#L23

timsehn commented 2 years ago

What error do you get when you try to send in an as of query? We can certainly add it as an option but I think reading the code that putting as of in the query itself should work.

kretes commented 2 years ago

Oh yes, that works!

The issue with adding 'as of' to the query is that this is an orthogonal concept to the query itself.

And so now I have the query written and need to modify it in multiple places (each of the tables that is there, this particular case is a join query) and put all that in client code.

Alternative is that I write a decorator that gets a query and returns a query with as of statements added - however every client would need to write this utility function. And this function is not 100% trivial if one wants to account for multiple places in which a table name (or maybe view name or anything else? ) can exist in the query - this basically would require to transform the query to an AST and modify that, I guess.

That's why I think the ultimate place for this functionality is the library, rather than client's code.

timsehn commented 2 years ago

Understood. I think we would face a similar problem in the library but might as well solve it on once place.