MCPcopy Index your code
hub / github.com/bytebase/bytebase / createViewDDL

Function createViewDDL

backend/plugin/parser/redshift/completion.go:169–191  ·  view source on GitHub ↗
(kind, schemaName, viewName string, columns []*storepb.ColumnMetadata)

Source from the content-addressed store, hash-verified

167}
168
169func createViewDDL(kind, schemaName, viewName string, columns []*storepb.ColumnMetadata) string {
170 selectItems := make([]string, 0, len(columns))
171 for _, column := range columns {
172 if column == nil || column.GetName() == "" {
173 continue
174 }
175 selectItems = append(selectItems, fmt.Sprintf(
176 "CAST(NULL AS %s) AS %s",
177 normalizeCompletionType(column.GetType()),
178 quoteIdent(column.GetName()),
179 ))
180 }
181 if len(selectItems) == 0 {
182 selectItems = append(selectItems, "1 AS __bytebase_completion_placeholder")
183 }
184 return fmt.Sprintf(
185 "CREATE %s %s.%s AS SELECT %s;",
186 kind,
187 quoteIdent(schemaName),
188 quoteIdent(viewName),
189 strings.Join(selectItems, ", "),
190 )
191}
192
193func createMaterializedViewDDL(schemaName, viewName, definition string) string {
194 definition = strings.TrimSpace(definition)

Callers 1

buildCompletionCatalogFunction · 0.85

Calls 5

normalizeCompletionTypeFunction · 0.85
JoinMethod · 0.80
quoteIdentFunction · 0.70
GetNameMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected