Skip to content

Commit

Permalink
Coerce null values to a null string
Browse files Browse the repository at this point in the history
  • Loading branch information
jakthom committed Dec 5, 2024
1 parent ad15974 commit 9f5ecfc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
File renamed without changes.
3 changes: 2 additions & 1 deletion hercules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ globalLabels:
- env: $ENV # Inject prometheus labels from env var

packages:
- package: hercules-packages/bluesky/1.0.yaml
# - package: hercules-packages/bluesky/1.0.yml
- package: hercules-packages/snowflake/1.0.yml
5 changes: 5 additions & 0 deletions pkg/db/constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package db

const (
NULL string = "null"
)
3 changes: 3 additions & 0 deletions pkg/db/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func Materialize(conn *sql.Conn, query Sql) ([]QueryResult, error) {
if columnName == "value" || columnName == "val" || columnName == "v" || isFunctionColumn(columnName) {
queryResult.Value = toFloat64(value)
} else {
if value == nil {
value = NULL // If the value is null, set it to a string value.
}
queryResult.Labels[columnName] = value.(string)
}
}
Expand Down

0 comments on commit 9f5ecfc

Please sign in to comment.