Skip to content
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

add aggregate expression types to fixture metadata #95

Merged
merged 8 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions fixtures/hasura/chinook/metadata/models/Invoice.hml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ definition:
graphql:
typeName: InvoiceComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: InvoiceAggregateExp
operand:
object:
aggregatedType: Invoice
aggregatableFields:
- fieldName: total
aggregateExpression: DecimalAggregateExp
count: { enable: true }
graphql:
selectTypeName: InvoiceAggregateExp

---
kind: Model
version: v1
Expand All @@ -133,6 +148,7 @@ definition:
source:
dataConnectorName: chinook
collection: Invoice
aggregateExpression: InvoiceAggregateExp
filterExpressionType: InvoiceComparisonExp
orderableFields:
- fieldName: id
Expand Down Expand Up @@ -166,6 +182,10 @@ definition:
orderByDirections:
enableAll: true
graphql:
aggregate:
queryRootField:
invoiceAggregate
filterInputTypeName: InvoiceFilterInput
selectMany:
queryRootField: invoice
selectUniques:
Expand Down
22 changes: 22 additions & 0 deletions fixtures/hasura/chinook/metadata/models/InvoiceLine.hml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ definition:
graphql:
typeName: InvoiceLineComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: InvoiceLineAggregateExp
operand:
object:
aggregatedType: InvoiceLine
aggregatableFields:
- fieldName: quantity
aggregateExpression: IntAggregateExp
- fieldName: unitPrice
aggregateExpression: DecimalAggregateExp
count: { enable: true }
graphql:
selectTypeName: InvoiceLineAggregateExp

---
kind: Model
version: v1
Expand All @@ -101,6 +118,7 @@ definition:
source:
dataConnectorName: chinook
collection: InvoiceLine
aggregateExpression: InvoiceLineAggregateExp
filterExpressionType: InvoiceLineComparisonExp
orderableFields:
- fieldName: id
Expand All @@ -122,6 +140,10 @@ definition:
orderByDirections:
enableAll: true
graphql:
aggregate:
queryRootField:
invoiceLineAggregate
filterInputTypeName: InvoiceLineFilterInput
selectMany:
queryRootField: invoiceLine
selectUniques:
Expand Down
24 changes: 24 additions & 0 deletions fixtures/hasura/chinook/metadata/models/Track.hml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ definition:
graphql:
typeName: TrackComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: TrackAggregateExp
operand:
object:
aggregatedType: Track
aggregatableFields:
- fieldName: unitPrice
aggregateExpression: DecimalAggregateExp
- fieldName: bytes
aggregateExpression: IntAggregateExp
- fieldName: milliseconds
aggregateExpression: IntAggregateExp
count: { enable: true }
graphql:
selectTypeName: TrackAggregateExp

---
kind: Model
version: v1
Expand All @@ -139,6 +158,7 @@ definition:
source:
dataConnectorName: chinook
collection: Track
aggregateExpression: TrackAggregateExp
filterExpressionType: TrackComparisonExp
orderableFields:
- fieldName: id
Expand Down Expand Up @@ -172,6 +192,10 @@ definition:
orderByDirections:
enableAll: true
graphql:
aggregate:
queryRootField:
trackAggregate
filterInputTypeName: TrackFilterInput
selectMany:
queryRootField: track
selectUniques:
Expand Down
29 changes: 29 additions & 0 deletions fixtures/hasura/common/metadata/scalar-types/Date.hml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,32 @@ definition:
graphql:
typeName: DateComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: DateAggregateExp
operand:
scalar:
aggregatedType: Date
aggregationFunctions:
- name: _max
returnType: Date
- name: _min
returnType: Date
dataConnectorAggregationFunctionMapping:
- dataConnectorName: chinook
dataConnectorScalarType: Date
functionMapping:
_max: { name: max }
_min: { name: min }
- dataConnectorName: sample_mflix
dataConnectorScalarType: Date
functionMapping:
_max: { name: max }
_min: { name: min }
count: { enable: true }
countDistinct: { enable: true }
graphql:
selectTypeName: DateAggregateExp

37 changes: 37 additions & 0 deletions fixtures/hasura/common/metadata/scalar-types/Decimal.hml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,40 @@ definition:
enable: true
graphql:
typeName: DecimalComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: DecimalAggregateExp
operand:
scalar:
aggregatedType: Decimal
aggregationFunctions:
- name: _avg
returnType: Decimal
- name: _max
returnType: Decimal
- name: _min
returnType: Decimal
- name: _sum
returnType: Decimal
dataConnectorAggregationFunctionMapping:
- dataConnectorName: chinook
dataConnectorScalarType: Decimal
functionMapping:
_avg: { name: avg }
_max: { name: max }
_min: { name: min }
_sum: { name: sum }
- dataConnectorName: sample_mflix
dataConnectorScalarType: Decimal
functionMapping:
_avg: { name: avg }
_max: { name: max }
_min: { name: min }
_sum: { name: sum }
count: { enable: true }
countDistinct: { enable: true }
graphql:
selectTypeName: DecimalAggregateExp
37 changes: 37 additions & 0 deletions fixtures/hasura/common/metadata/scalar-types/Double.hml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,40 @@ definition:
enable: true
graphql:
typeName: DoubleComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: FloatAggregateExp
operand:
scalar:
aggregatedType: Float
aggregationFunctions:
- name: _avg
returnType: Float
- name: _max
returnType: Float
- name: _min
returnType: Float
- name: _sum
returnType: Float
dataConnectorAggregationFunctionMapping:
- dataConnectorName: chinook
dataConnectorScalarType: Double
functionMapping:
_avg: { name: avg }
_max: { name: max }
_min: { name: min }
_sum: { name: sum }
- dataConnectorName: sample_mflix
dataConnectorScalarType: Double
functionMapping:
_avg: { name: avg }
_max: { name: max }
_min: { name: min }
_sum: { name: sum }
count: { enable: true }
countDistinct: { enable: true }
graphql:
selectTypeName: FloatAggregateExp
37 changes: 37 additions & 0 deletions fixtures/hasura/common/metadata/scalar-types/Int.hml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,40 @@ definition:
enable: true
graphql:
typeName: IntComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: IntAggregateExp
operand:
scalar:
aggregatedType: Int
aggregationFunctions:
- name: _avg
returnType: Int
Comment on lines +71 to +74
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type for averages over Int should be Float. We need to fix that in the connector capabilities. I filed an issue to follow up on this, https://linear.app/hasura/issue/NDC-385/return-type-for-average-of-ints-should-be-float-not-int

- name: _max
returnType: Int
- name: _min
returnType: Int
- name: _sum
returnType: Int
dataConnectorAggregationFunctionMapping:
- dataConnectorName: chinook
dataConnectorScalarType: Int
functionMapping:
_avg: { name: avg }
_max: { name: max }
_min: { name: min }
_sum: { name: sum }
- dataConnectorName: sample_mflix
dataConnectorScalarType: Int
functionMapping:
_avg: { name: avg }
_max: { name: max }
_min: { name: min }
_sum: { name: sum }
count: { enable: true }
countDistinct: { enable: true }
graphql:
selectTypeName: IntAggregateExp
25 changes: 22 additions & 3 deletions fixtures/hasura/sample_mflix/metadata/models/Comments.hml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ definition:
graphql:
typeName: CommentsComparisonExp

---
kind: AggregateExpression
version: v1
definition:
name: CommentsAggregateExp
operand:
object:
aggregatedType: Comments
aggregatableFields:
- fieldName: date
aggregateExpression: DateAggregateExp
count: { enable: true }
graphql:
selectTypeName: CommentsAggregateExp

---
kind: Model
version: v1
Expand All @@ -109,6 +124,7 @@ definition:
source:
dataConnectorName: sample_mflix
collection: comments
aggregateExpression: CommentsAggregateExp
filterExpressionType: CommentsComparisonExp
orderableFields:
- fieldName: id
Expand All @@ -130,6 +146,9 @@ definition:
orderByDirections:
enableAll: true
graphql:
aggregate:
queryRootField: commentsAggregate
filterInputTypeName: CommentsFilterInput
selectMany:
queryRootField: comments
selectUniques:
Expand All @@ -149,12 +168,12 @@ definition:
filter: null
- role: user
select:
filter:
filter:
relationship:
name: user
predicate:
predicate:
fieldComparison:
field: id
operator: _eq
value:
value:
sessionVariable: x-hasura-user-id
Loading
Loading