use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class KsqlStructuredDataOutputNode method validate.
private static void validate(final PlanNode source, final SourceName sinkName) {
if (!(source instanceof VerifiableNode)) {
throw new IllegalArgumentException("VerifiableNode required");
}
((VerifiableNode) source).validateKeyPresent(sinkName);
final LogicalSchema schema = source.getSchema();
final String duplicates = schema.columns().stream().map(Column::name).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream().filter(e -> e.getValue() > 1).map(Entry::getKey).map(ColumnName::toString).collect(Collectors.joining(", "));
if (!duplicates.isEmpty()) {
throw new IllegalArgumentException("Value columns clash with key columns: " + duplicates);
}
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class PreJoinProjectNode method buildSchema.
private static LogicalSchema buildSchema(final SourceName alias, final LogicalSchema parentSchema) {
final LogicalSchema.Builder builder = LogicalSchema.builder();
parentSchema.columns().forEach(c -> {
final ColumnName aliasedName = ColumnNames.generatedJoinColumnAlias(alias, c.name());
if (c.namespace() == Namespace.KEY) {
builder.keyColumn(aliasedName, c.type());
} else {
builder.valueColumn(aliasedName, c.type());
}
});
return builder.build();
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class PreJoinProjectNodeTest method shouldNotAddAliasOnResolveSelectStarWhenNotAliased.
@Test
public void shouldNotAddAliasOnResolveSelectStarWhenNotAliased() {
// Given:
final ColumnName unknown = ColumnName.of("unknown");
when(source.resolveSelectStar(any())).thenReturn(ImmutableList.of(K, unknown).stream());
// When:
final Stream<ColumnName> result = projectNode.resolveSelectStar(Optional.empty());
// Then:
final List<ColumnName> columns = result.collect(Collectors.toList());
assertThat(columns, contains(K, unknown));
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class ColumnReferenceParserTest method shouldParseQuotedIdentifier.
@Test
public void shouldParseQuotedIdentifier() {
// When:
final ColumnName result = ColumnReferenceParser.parse("`foo`");
// Then:
assertThat(result, is(ColumnName.of("foo")));
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class ColumnReferenceParserTest method shouldParseUnquotedIdentifier.
@Test
public void shouldParseUnquotedIdentifier() {
// When:
final ColumnName result = ColumnReferenceParser.parse("foo");
// Then:
assertThat(result, is(ColumnName.of("FOO")));
}
Aggregations