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

Fix aggregate bug #152

Merged
merged 2 commits into from
Nov 2, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Build
runs-on: ubuntu-latest
env:
SCYLLA_IMAGE: scylladb/scylla:4.6.3
SCYLLA_IMAGE: scylladb/scylla:5.2.9
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ services:
node_1:
image: ${SCYLLA_IMAGE}
privileged: true
command: --smp 2 --memory 768M --seeds 192.168.100.11 --overprovisioned 1
command: |
--smp 2
--memory 768M
--seeds 192.168.100.11
--overprovisioned 1
--experimental-features udf
--enable-user-defined-functions true
networks:
public:
ipv4_address: 192.168.100.11
Expand Down
10 changes: 5 additions & 5 deletions recreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ var functionTemplate = template.Must(template.New("functions").
"stripFrozen": cqlHelpers.stripFrozen,
}).
Parse(`
CREATE FUNCTION {{ escape .keyspaceName }}.{{ escape .fm.Name }} (
CREATE FUNCTION {{ .keyspaceName }}.{{ .fm.Name }} (
{{- range $i, $args := zip .fm.ArgumentNames .fm.ArgumentTypes }}
{{- if ne $i 0 }}, {{ end }}
{{- escape (index $args 0) }}
{{- (index $args 0) }}
{{ stripFrozen (index $args 1) }}
{{- end -}})
{{ if .fm.CalledOnNullInput }}CALLED{{ else }}RETURNS NULL{{ end }} ON NULL INPUT
Expand Down Expand Up @@ -167,19 +167,19 @@ var aggregatesTemplate = template.Must(template.New("aggregate").
}).
Parse(`
CREATE AGGREGATE {{ .Keyspace }}.{{ .Name }}(
{{- range $arg, $i := .ArgumentTypes }}
{{- range $i, $arg := .ArgumentTypes }}
{{- if ne $i 0 }}, {{ end }}
{{ stripFrozen $arg }}
{{- end -}})
SFUNC {{ .StateFunc.Name }}
STYPE {{ stripFrozen .State }}
STYPE {{ stripFrozen .StateType }}
{{- if ne .FinalFunc.Name "" }}
FINALFUNC {{ .FinalFunc.Name }}
{{- end -}}
{{- if ne .InitCond "" }}
INITCOND {{ .InitCond }}
{{- end -}}
);
;
`))

func (km *KeyspaceMetadata) aggregateToCQL(w io.Writer, am *AggregateMetadata) error {
Expand Down
6 changes: 6 additions & 0 deletions recreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ func TestRecreateSchema(t *testing.T) {
Input: "testdata/recreate/udt.cql",
Golden: "testdata/recreate/udt_golden.cql",
},
{
Name: "Aggregates",
Keyspace: "gocqlx_aggregates",
Input: "testdata/recreate/aggregates.cql",
Golden: "testdata/recreate/aggregates_golden.cql",
},
}

for i := range tcs {
Expand Down
31 changes: 31 additions & 0 deletions testdata/recreate/aggregates.cql