Comments (3)
I think the best approach is to create a new sublist named secondary_queries
which is a list containing one or more queries. This sublist should have an attribute named relationship
which is a vector of character strings such as "union all"
or "union distinct"
:
Option 3:
$select
$select[[1]]
x$from
$from[[1]]
df1$secondary_queries
$secondary_queries[[1]]
$secondary_queries[[1]]$select
$secondary_queries[[1]]$select[[1]]
x$secondary_queries[[1]]$from
$secondary_queries[[1]]$from[[1]]
df2attr(,"relationship")
[1] "union distinct"
This same structure could later support CTEs and subqueries (by naming the items in secondary_queries
and then referring to those table names elsewhere in the query). I think it's best to use one unified structure like this to support set operations, CTEs, and subqueries.
from queryparser.
That may be tough to parse with complicated nesting structures. CTEs are particularly difficult because they may be seconday_queries
to multiple levels. For example, in this query, some_cte
is a subquery of both df1
(the main/leader set) and df2
(the secondary set):
WITH some_cte
AS (SELECT ...)
SELECT *
FROM df1
WHERE x IN (SELECT y from some_cte)
UNION ALL
SELECT *
FROM df2
WHERE x IN (SELECT y from some_cte)
If we keep the overall structure similar to the original query, it may be easier to parse. I'm not familiar with the changes that would need to be made in tidyquery, though.
from queryparser.
Yep, this will require some deeper thinking about the design before we make any decisions. I have some other urgent work to do in the next few weeks, so I can't commit much time to it now, but I'm happy to keep discussing ideas here.
I think the secondary_queries
approach could handle cases like in your example above; when I get a chance, I'll describe how.
from queryparser.
Related Issues (20)
- Translation of multiple CAST and BETWEEN in one expression fails HOT 1
- Set an attribute indicating whether each expression in the ORDER BY list aggregates HOT 1
- Translate NULLS FIRST and NULLS LAST in ORDER BY clause
- Errors in translation of BETWEEN expressions with quoted operands when tidyverse = FALSE
- Remove line comments and block comments from query
- Translation of coalesce() fails when tidyverse = FALSE and arguments are expressions
- Add support for CASE expressions when tidyverse = TRUE HOT 1
- Translate coalesce() to a vectorized expression when tidyverse = FALSE
- Add support for CASE expressions when tidyverse = FALSE
- Add support for table aliases HOT 1
- Add support for SQL-92-style join queries
- Fix problems with non-ASCII characters in queries HOT 1
- Allow parentheses enclosing table names and joins in FROM clause HOT 1
- Parse queries with no whitespace characters separating keywords
- Add tests for translations in translations.R HOT 3
- Add translation for substring_index() HOT 6
- Silence "truncating string with embedded nuls" warnings
- Allow syntactically invalid column names in backticks HOT 2
- Throw error if called from an incompatible version of tidyquery HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from queryparser.