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

WIP More info about columns #1071

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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: 2 additions & 0 deletions quesma/comment_metadata/comment_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

const ElasticFieldName = "fieldName"
const CreatedAt = "createdAt"
const CreatedBy = "createdBy"

const metadataVersion = "1"
const metadataPrefix = "quesmaMetadata"
Expand Down
5 changes: 5 additions & 0 deletions quesma/ingest/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/QuesmaOrg/quesma/quesma/util"
"slices"
"strings"
"time"
)

const NestedSeparator = "::"
Expand Down Expand Up @@ -54,6 +55,8 @@ func columnsToString(columnsFromJson []CreateTableEntry,

columnMetadata := comment_metadata.NewCommentMetadata()
columnMetadata.Values[comment_metadata.ElasticFieldName] = propertyName
columnMetadata.Values[comment_metadata.CreatedAt] = time.Now().UTC().Format(time.RFC3339)
columnMetadata.Values[comment_metadata.CreatedBy] = "QuesmaIngestNewTable"
comment := columnMetadata.Marshall()

if columnFromSchema, found := columnsFromSchema[schema.FieldName(columnFromJson.ClickHouseColumnName)]; found && !strings.Contains(columnFromJson.ClickHouseType, "Array") {
Expand All @@ -78,6 +81,8 @@ func columnsToString(columnsFromJson []CreateTableEntry,

columnMetadata := comment_metadata.NewCommentMetadata()
columnMetadata.Values[comment_metadata.ElasticFieldName] = propertyName
columnMetadata.Values[comment_metadata.CreatedAt] = time.Now().UTC().Format(time.RFC3339)
columnMetadata.Values[comment_metadata.CreatedBy] = "QuesmaIngestNewTable"
comment := columnMetadata.Marshall()

result.WriteString(util.Indent(1))
Expand Down
2 changes: 2 additions & 0 deletions quesma/ingest/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ func (ip *IngestProcessor) generateNewColumns(

metadata := comment_metadata.NewCommentMetadata()
metadata.Values[comment_metadata.ElasticFieldName] = propertyName
metadata.Values[comment_metadata.CreatedAt] = time.Now().UTC().Format(time.RFC3339)
metadata.Values[comment_metadata.CreatedBy] = "QuesmaIngestAlter"
comment := metadata.Marshall()

alterTable := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN IF NOT EXISTS \"%s\" %s", table.Name, attrKeys[i], columnType)
Expand Down
Loading