(kind, schemaName, viewName string, columns []*storepb.ColumnMetadata)
| 167 | } |
| 168 | |
| 169 | func 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 | |
| 193 | func createMaterializedViewDDL(schemaName, viewName, definition string) string { |
| 194 | definition = strings.TrimSpace(definition) |
no test coverage detected