-
Notifications
You must be signed in to change notification settings - Fork 56
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
Rewrite SQL builders, make substantial project updates. #586
Conversation
Sweet. I'll take a deeper look soon. |
package-lock.json
Outdated
@@ -4184,6 +4184,10 @@ | |||
"resolved": "packages/sql", | |||
"link": true | |||
}, | |||
"node_modules/@uwdata/mosaic-sql-old": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, will fix!
packages/sql/src/visit/visitors.js
Outdated
import { walk } from './walk.js'; | ||
|
||
const aggrRegExp = new RegExp(`^(${aggregateNames.join('|')})`); | ||
const funcRegExp = /(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+|\w+\()/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be more readable with comments.
const funcRegExp = /(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+|\w+\()/g; | |
const funcRegExp = /( | |
\\' | // Matches an escaped single quote (e.g., \') | |
\\" | // Matches an escaped double quote (e.g., \") | |
"(?:\\"|[^"])*" | // Matches a double-quoted string, allowing for escaped quotes (e.g., "text with \"escaped\" quotes") | |
'(?:\\'|[^'])*' | // Matches a single-quoted string, allowing for escaped quotes (e.g., 'text with \'escaped\' quotes') | |
\$\w+ | // Matches a variable starting with $ followed by word characters (e.g., $variableName) | |
\w+\( // Matches a function name, capturing any word characters followed by an opening parenthesis (e.g., functionName() | |
)/g; |
const value = node[props[i]]; | ||
if (Array.isArray(value)) { | ||
const m = value.length; | ||
for (let j = 0; j < m; ++j) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a for...of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could, but I wanted to keep the loops tight in cases of larger queries/expressions to walk. Using iterators adds non-trivial overhead. Maybe wouldn't really matter in this case, but I prefer to default to the more performant case for internals like this.
packages/sql/src/transforms/m4.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice to have this outside of vgplot now
mosaic-sql
package to use a complete AST formulation. Add additional SQL helper methods.agg
SQL expression helper. We now perform automatic analysis to determine if an expression is an aggregate expression.mosaic-sql
package in a newtransforms
folder.mosaic-core/preagg
folder.mosaic-sql
andmosaic-core
.