-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support SELECT * EXCEPT (col1, col2)
-style functionality
#90
Conversation
d279cba
to
7963631
Compare
7963631
to
09de192
Compare
a97735c
to
68000ea
Compare
09de192
to
1b3c992
Compare
a602a0b
to
23eaeaf
Compare
1d1adf1
to
eb5771e
Compare
* EXCEPT (col1, col2)
-style functionalitySELECT * EXCEPT (col1, col2)
-style functionality
@@ -22,14 +22,14 @@ | |||
- parse - a parsing function" | |||
[s db parse] | |||
(let [node-or-failure (parse s)] | |||
(tap> #:base.query{:node node-or-failure}) |
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.
interesting, do you recommend leaving this in for production code? I like the idea of more logging via tap>
, I just don't know good practices yet.
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.
Zane requested this. The nice thing about tap>
is it's very lightweight if no taps are added.
The less nice thing about tap>
is well, everything else, IMO. :P I've tried REBL and Portal, and have yet to find a tap/datafy visualizer I actually think is worth using over logs. They're just so slow to navigate in.
For now, I've taken to running:
(do
(when (ns-resolve 'user 'log-tap)
(remove-tap user/log-tap))
(intern 'user 'log-tap #(do (prn %) (println)))
(add-tap user/log-tap))
so I get some semblance of logs.
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.
I’m happy to be overruled here if you two align on a different solution for logging!
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.
@sritchie What, if anything, is OpenGen using for logging?
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.
Nothing now... in Emmy I have used Timbre but I'm not doing anything special to consume the logs.
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.
I guess the question is, what problem are we trying to solve? Is this for us, in our debugging efforts? Is this for debugging some eventually-deployed cloud system? Is this for 3rd-party users to get more insight into debugging their own queries? Some weighted combination of all of the above? We can't choose a solution when we haven't articulated the problem.
FWIW, I'm a fan of mulog, and other structured logging libs like pedestal.log. Timbre's not structured, iiuc, but it's already cross-platform, and it eliminates much of the need to fiddle with Java logging backend config files, which are both major pluses, especially for downstream users.
For now, I think it's fine to leave the tap>
's in, but I might add a logging helper for it.
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.
We can't choose a solution when we haven't articulated the problem.
For me, I find it help for debugging, since I can see all output at once, and search the REPL if necessary. Cloud servers are a future problem, imo. And I feel I don't know enough about third-party users yet to offer an opinion.
(star? (first selections))) | ||
op | ||
plan (cond (star? (first selections)) | ||
(select-star-plan (first selections) op) |
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.
can this ever fail? Can we get an empty selections input?
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.
Good question. I checked, but all my attempts result in parse errors. I don't think we can reach this code without something in the selections.
src/inferenceql/query/plan.cljc
Outdated
|
||
;; FIXME?: Can't currently combine GROUP BY and SELECT *, which some dbs allow |
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.
do you want to handle this, or make a ticket to track this?
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.
Yeah, the next step wasn't very clear. I thought Zane might be the person to ask, but he's not around. I suspect Ulli won't care much.
I dug around a bit to see which dbs do this, and the behavior I'm thinking of is an old, nonstandard default of MySQL's (what I cut my teeth on). In that light, it's probably better to delete this.
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.
Removed.
src/inferenceql/query/tuple.cljc
Outdated
@@ -24,7 +24,7 @@ | |||
(defn select-attrs | |||
"Retrives tuple `tup` with only the attributes in `attrs`." | |||
[tup attrs] | |||
(let [names (into #{} (map name) attrs)] | |||
(let [names (into #{} (map name) attrs)] ; FIXME: should this be clojure.core/name? |
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.
let's get this one resolved. Reviewing this sort of PR is where I miss types, I can't see what attrs
should be...
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.
I'm 99% certain it's a vec of keys (which should be strings these days), based on the attribute code I see elsewhere. In that case, it should almost certainly be clojure.core/name
here.
I think the reason nobody's noticed the error is because the select-attrs
fn is only called in i.q.relation/project
, which is never used.
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.
Yep, that's it:
(-> (strict/q "SELECT * FROM tbl LIMIT 1" db)
first
(tuple/select-attrs #{"Launch_Site" "Contractor"}))
=> {}
(defn select-attrs
"Retrives tuple `tup` with only the attributes in `attrs`."
[tup attrs]
(let [names (into #{} (map clojure.core/name) attrs)]
(medley/filter-keys (comp names clojure.core/name)
tup)))
=> #'inferenceql.query.tuple/select-attrs
(-> (strict/q "SELECT * FROM tbl LIMIT 1" db)
first
(tuple/select-attrs #{"Launch_Site" "Contractor"}))
=> {"Launch_Site" "Cape Canaveral", "Contractor" "Lockheed Martin"}
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.
Fixed.
6e8700b
to
90cfd70
Compare
90cfd70
to
f7adbed
Compare
@sritchie Got time for a re-review? I think I addressed everything. |
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.
Great work, !
f7adbed
to
3823297
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
- Coverage 76.26% 75.87% -0.39%
==========================================
Files 30 30
Lines 1462 1484 +22
Branches 52 60 +8
==========================================
+ Hits 1115 1126 +11
- Misses 295 298 +3
- Partials 52 60 +8 ☔ View full report in Codecov by Sentry. |
This adds
SELECT * EXCEPT (col-i-dont-want, col-that-annoys-me) ...
functionality to GenSQL.Adding
* EXCEPT
to other areas (conditioning, generation) will come in future PRs.