-
Notifications
You must be signed in to change notification settings - Fork 27
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
Clean up codegen export with quoted symbols #151
Open
ezmiller
wants to merge
6
commits into
master
Choose a base branch
from
ethan/improve-codegen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9282faa
Use more quoted symbols
ezmiller e6b4414
Finish exporting quoted symbols for tablecloth.api.operators
ezmiller 3b83b14
Avoid some qualified symbols in tablecloth.column.api
ezmiller e8e2495
Generate quoted symbols without symbol hack
ezmiller e398c4e
Export quoted symbols not qualified ones for tablecloth.api
ezmiller 5d8a2b2
Fix docstring in tablecloth.api.operators
ezmiller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,13 +42,13 @@ | |
(format | ||
"Applies the operation %s to the columns selected by | ||
`columns-selector` and returns a new ds with the the result in | ||
`target-col`. %s | ||
`target-col`. | ||
|
||
`columns-selector can be: | ||
- name | ||
- sequence of names | ||
- map of names with new names (rename) | ||
- function which filter names (via column metadata)" | ||
columns-selector can be: | ||
- name | ||
- sequence of names | ||
- map of names with new names (rename) | ||
- function which filter names (via column metadata)" | ||
fn-sym | ||
(when (< max-allowed Double/POSITIVE_INFINITY) | ||
(format | ||
|
@@ -66,42 +66,40 @@ | |
[fn-sym {:keys [return-ds? make-aggregator?] | ||
:or {return-ds? false | ||
make-aggregator? false}}] | ||
(let [defn (symbol "defn") | ||
let (symbol "let") | ||
arglists (get-arglists fn-sym) | ||
(let [arglists (get-arglists fn-sym) | ||
max-cols (max-cols-allowed arglists) | ||
lifted-arglists (convert-arglists arglists return-ds?) | ||
new-fn-sym (symbol (name fn-sym)) | ||
new-docstring (build-docstring fn-sym)] | ||
`(~defn ~new-fn-sym | ||
`(~'defn ~new-fn-sym | ||
~new-docstring | ||
~@(for [args lifted-arglists] | ||
(if make-aggregator? | ||
;; build an aggregator fn | ||
`(~args | ||
(~let [aggregator# | ||
(fn [ds#] | ||
(~let [ds-with-selected-cols# | ||
(~'let [aggregator# | ||
(~'fn [ds#] | ||
(~'let [ds-with-selected-cols# | ||
(select-columns ds# ~'columns-selector) | ||
cols-count# | ||
(-> ds-with-selected-cols# | ||
(~'-> ds-with-selected-cols# | ||
column-names | ||
count) | ||
~'count) | ||
selected-cols# (columns ds-with-selected-cols#)] | ||
(if (>= ~max-cols cols-count#) | ||
(apply ~fn-sym (apply vector selected-cols#)) | ||
(throw (Exception. (str "Exceeded maximum number of columns allowed for operation."))))))] | ||
(~'if (>= ~max-cols cols-count#) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(~'apply ~fn-sym (~'apply ~'vector selected-cols#)) | ||
(throw (Exception. (~'str "Exceeded maximum number of columns allowed for operation."))))))] | ||
(aggregate ~'ds aggregator#))) | ||
;; build either a fn that returns a dataset or the result of the operation | ||
`(~args | ||
(~let [selected-cols# (apply vector (columns | ||
(~'let [selected-cols# (~'apply ~'vector (columns | ||
(select-columns ~'ds ~'columns-selector))) | ||
args-to-pass# (concat selected-cols# [~@(drop 3 args)])] | ||
(if (>= ~max-cols (count selected-cols#)) | ||
(->> args-to-pass# | ||
(apply ~fn-sym) | ||
args-to-pass# (~'concat selected-cols# [~@(drop 3 args)])] | ||
(~'if (>= ~max-cols (~'count selected-cols#)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here: |
||
(~'->> args-to-pass# | ||
(~'apply ~fn-sym) | ||
~(if return-ds? `(add-or-replace-column ~'ds ~'target-col) `(identity))) | ||
(throw (Exception. (str "Exceeded maximum number of columns allowed for operation."))))))))))) | ||
(throw (Exception. (~'str "Exceeded maximum number of columns allowed for operation."))))))))))) | ||
|
||
(def serialized-lift-fn-lookup | ||
{'[distance | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ds#
->~'ds
- it will generate more clean code