Skip to content

Commit

Permalink
Fix bug where emit with brackets caused an excception (#619)
Browse files Browse the repository at this point in the history
This bug was introduced when taking the last name of a property chain as tha name of the column.
  • Loading branch information
Ulimo authored Nov 28, 2024
1 parent 6eebdb7 commit e2afe30
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/FlowtideDotNet.Substrait/Sql/EmitData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,16 @@ public bool TryGetEmitIndex(
seg = newSegment;
}

var lastIdentifier = mapIdentifiers.Last();
name = lastIdentifier; // Use the last identifier as name
if (mapIdentifiers.Count > 0)
{
var lastIdentifier = mapIdentifiers.Last();
name = lastIdentifier; // Use the last identifier as name
}
else
{
name = GetName(emitInfoPartial.Index[0]);
}


// TODO: For now we just return any type, but we should try to find the correct type
type = new AnyType();
Expand Down
9 changes: 9 additions & 0 deletions tests/FlowtideDotNet.AcceptanceTests/SelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public async Task SelectOneColumnsWithoutId()
AssertCurrentDataEqual(Users.Select(x => new { x.FirstName }));
}

[Fact]
public async Task SelectOneColumnsWithTableAliasAndBrackets()
{
GenerateData();
await StartStream("INSERT INTO output SELECT u.[firstName] FROM users u");
await WaitForUpdate();
AssertCurrentDataEqual(Users.Select(x => new { x.FirstName }));
}

[Fact]
public async Task SelectOneColumnsWithoutIdAndUpdate()
{
Expand Down

1 comment on commit e2afe30

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e2afe30 Previous: 7db1083 Ratio
FlowtideDotNet.Benchmarks.Stream.StreamBenchmark.InnerJoin 547547330 ns (± 9806962.326389462) 588638700 ns (± 9231369.002121696) 0.93
FlowtideDotNet.Benchmarks.Stream.StreamBenchmark.LeftJoin 643246000 ns (± 26235090.261041604) 632393477.7777778 ns (± 23156158.76418074) 1.02
FlowtideDotNet.Benchmarks.Stream.StreamBenchmark.ProjectionAndNormalization 205533750 ns (± 15728424.213947464) 171268600 ns (± 6644227.006958748) 1.20
FlowtideDotNet.Benchmarks.Stream.StreamBenchmark.SumAggregation 215746200 ns (± 10021434.508758381) 190822830 ns (± 6415026.852121856) 1.13
FlowtideDotNet.Benchmarks.Stream.StreamBenchmark.ListAggWithMapAggregation 2370286230 ns (± 119160366.21019077) 2656394200 ns (± 136074715.58524996) 0.89

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.