-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat: Add the count aggregate function #972
Merged
danieljbruce
merged 76 commits into
googleapis:main
from
danieljbruce:count-aggregation-only-relevant-changes
Jan 12, 2023
Merged
Changes from 71 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
fe55548
Files copied over
danieljbruce f84ebdd
implementation of aggregate queries.
danieljbruce 259141c
Checkout index.ts previous version
danieljbruce 8d8a01f
src seems to be error free
danieljbruce c88009e
optional parameters
danieljbruce f542235
replace with recognized type
danieljbruce 1b21ec2
protos generated
danieljbruce 83586e7
old package.json
danieljbruce 0f2bd32
aggregation query request
danieljbruce 5469ebc
Commit so I can revert
danieljbruce 1733072
Revert "aggregation query request"
danieljbruce 7a99e8c
Revert "Revert "aggregation query request""
danieljbruce 7e4d53a
Added a parser
danieljbruce 7290af7
Comment out filters
danieljbruce efe0826
Fixed parser
danieljbruce 6aa110c
Add info
danieljbruce 2de1518
more tests, adding alias
danieljbruce e36dcde
use deep strict equal instead
danieljbruce 6e85612
Work on passing in buffered input.
danieljbruce 7e87274
Convert to buffer
danieljbruce 477a199
Add alias
danieljbruce 5ffafd6
Add the aggregate function
danieljbruce cc602be
change test descriptions
danieljbruce 5de6f5c
Add a unit test
danieljbruce 5639d42
Revert "Files copied over"
danieljbruce 5143df3
Revert "protos generated"
danieljbruce 4329129
Eliminate comments
danieljbruce b0c05b8
Merge branch 'count-aggregation-2' of https://github.com/danieljbruce…
danieljbruce cd82996
Add new line
danieljbruce 35ab76d
Merge branch 'count-aggregation-2' of https://github.com/danieljbruce…
danieljbruce b58a1d5
Change upTo
danieljbruce 377d857
Change maximum name to upTo
danieljbruce 3e74452
upTo relabelled from maximum
danieljbruce 6e11243
remove import
danieljbruce 1225d24
ran the linter
danieljbruce 2d4386b
improve code readability
danieljbruce db9c340
move self equals this
danieljbruce b3ea976
change header
danieljbruce 7e9d018
Revert "change header"
danieljbruce bb839a3
Add a header
danieljbruce 5f5a815
change the unit test
danieljbruce bd97895
Architecture changes
danieljbruce 9b0943c
Getting closer
danieljbruce 3ed910a
Add the right parsing
danieljbruce 60a3486
TODO message
danieljbruce 83dad3b
Remove and add array over for aggregate fields
danieljbruce 5370810
unit test and count function
danieljbruce b6278b3
fix unit test as result of new changes
danieljbruce eca8b33
linting fix
danieljbruce 8fa14af
Added a test for encoding using a count function
danieljbruce 5acff03
lint fix
danieljbruce a79f742
Merge branch 'main' into count-aggregation-only-relevant-changes
telpirion 6766066
removed upTo
8c6748a
Merge branch 'main' into count-aggregation-only-relevant-changes
telpirion 881a800
merge
c09d548
undid local changes to package.json
794314e
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] b13b5e9
Update src/aggregate.ts
telpirion 872675e
per reviewer
7cc59b7
Merge branch 'main' into count-aggregation-only-relevant-changes
telpirion cbce348
Merge branch 'main' into count-aggregation-only-relevant-changes
telpirion 2b08cb5
refactor and rename some methods
kolea2 27d1365
Add run method to aggregate query
danieljbruce 450a519
test update and return value change
danieljbruce f9acad7
compare aggregate results
danieljbruce 72e412f
Merge branch 'main' into count-aggregation-only-relevant-changes
danieljbruce 25e3b95
createAggregationQuery
danieljbruce 28d5b60
Merge branch 'count-aggregation-only-relevant-changes' of https://git…
danieljbruce 5707db9
linter and header fix
danieljbruce 0874935
TODOs
danieljbruce 4af78aa
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] f8d771e
Remove autogenerated comment
danieljbruce 1f094d8
Merge branch 'count-aggregation-only-relevant-changes' of https://git…
danieljbruce 77f3e59
count aggregation with limit filter tests
danieljbruce 088c844
lint fix
danieljbruce 6c23ccb
Commented functions and classes
danieljbruce 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ** This file is automatically generated by gapic-generator-typescript. ** | ||
// ** https://github.com/googleapis/gapic-generator-typescript ** | ||
// ** All changes to this file may be overwritten. ** | ||
|
||
import {Query} from './index'; | ||
import {RunQueryOptions, RunQueryResponse} from './query'; | ||
import {RequestCallback} from './request'; | ||
const AGGREGATE_QUERY = Symbol('AGGREGATE_QUERY'); | ||
|
||
class AggregateQuery { | ||
type = AGGREGATE_QUERY; | ||
aggregations: Array<AggregateField>; | ||
query: Query | undefined; | ||
|
||
constructor(query: Query) { | ||
this.query = query; | ||
this.aggregations = []; | ||
} | ||
|
||
count(alias: string): AggregateQuery { | ||
this.aggregations.push(AggregateField.count().alias(alias)); | ||
return this; | ||
} | ||
|
||
addAggregation(aggregation: AggregateField): AggregateQuery { | ||
this.aggregations.push(aggregation); | ||
return this; | ||
} | ||
|
||
addAggregations(aggregations: AggregateField[]): AggregateQuery { | ||
for (const aggregation of aggregations) { | ||
this.aggregations.push(aggregation); | ||
} | ||
return this; | ||
} | ||
|
||
run( | ||
optionsOrCallback?: RunQueryOptions | RequestCallback, | ||
cb?: RequestCallback | ||
): void | Promise<RunQueryResponse> { | ||
const options = | ||
typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; | ||
const callback = | ||
typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; | ||
const scope = this.query!.scope; | ||
const runAggregationQuery = scope!.runAggregationQuery.bind(scope); | ||
return runAggregationQuery(this, options, callback); | ||
} | ||
|
||
// eslint-disable-next-line | ||
toProto(): any { | ||
telpirion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return this.aggregations.map(aggregation => aggregation.toProto()); | ||
} | ||
} | ||
|
||
abstract class AggregateField { | ||
alias_?: string; | ||
telpirion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static count(): Count { | ||
return new Count(); | ||
} | ||
|
||
alias(alias: string): AggregateField { | ||
this.alias_ = alias; | ||
return this; | ||
} | ||
|
||
// eslint-disable-next-line | ||
abstract toProto(): any; | ||
} | ||
|
||
class Count extends AggregateField { | ||
// eslint-disable-next-line | ||
toProto(): any { | ||
const count = Object.assign({}); | ||
return Object.assign({count}, this.alias_ ? {alias: this.alias_} : null); | ||
} | ||
} | ||
|
||
export {AggregateField, AggregateQuery, AGGREGATE_QUERY}; | ||
telpirion marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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
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
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.
Is the notice correct that this is autogenerated?
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 is not autogenerated. Thanks for catching this one! Changes pushed.