Skip to content

Commit

Permalink
fix clickhouse tutorial and timestamp parsing, bump v4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Jan 23, 2024
1 parent ddc5ba9 commit 3f4a60e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

* Fixed the timestamp parsing in Clickhouse dialect.
* Fixed the schema in the tutorial for clickhouse.
* Bump version of `schema` dependency to fix errors with new Clickhouse versions now using `system.tables` table instead of `information_schema.tables` view.
* Add `--network` flag to override the default value in the manifest or spkg

## v4.0.0-rc.3
## v4.0.0

* Fix a critical bug breaking the reorg management when more than one row needs to be reverted.

Expand Down
8 changes: 7 additions & 1 deletion db/dialect_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,13 @@ func convertToType(value string, valueType reflect.Type) (any, error) {
return int64(i), nil
}

v, err := time.Parse("2006-01-02T15:04:05Z", value)
var v time.Time
var err error
if strings.Contains(value, "T") && strings.HasSuffix(value, "Z") {
v, err = time.Parse("2006-01-02T15:04:05Z", value)
} else {
v, err = time.Parse("2006-01-02 15:04:05", value)
}
if err != nil {
return "", fmt.Errorf("could not convert %s to time: %w", value, err)
}
Expand Down
17 changes: 0 additions & 17 deletions docs/tutorial/schema-clickhouse.sql

This file was deleted.

8 changes: 8 additions & 0 deletions docs/tutorial/schema.clickhouse.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS block_meta (
"id" VARCHAR(64),
"at" VARCHAR(64),
"number" UInt64,
"hash" VARCHAR(64),
"parent_hash" VARCHAR(64),
"timestamp" VARCHAR(64),
) ENGINE = MergeTree PRIMARY KEY ("id");
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ sink:
module: db_out
type: sf.substreams.sink.sql.v1.Service
config:
schema: "./schema.sql"
wire_protocol_access: true
schema: "./schema.clickhouse.sql"
engine: clickhouse
postgraphile_frontend:
enabled: false
Expand Down

0 comments on commit 3f4a60e

Please sign in to comment.