Skip to content

Commit

Permalink
show warning only on tables . prevents warnign on Table(First(DS))
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaselv committed Mar 12, 2024
1 parent 53aa731 commit 121d1e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public override void CheckSemantics(TexlBinding binding, TexlNode[] args, DType[
{
var ads = argTypes[i].AssociatedDataSources?.FirstOrDefault();

if (ads is IExternalTabularDataSource)
if (argTypes[i].IsTableNonObjNull && ads is IExternalTabularDataSource)
{
errors.EnsureError(DocumentErrorSeverity.Warning, args[i], TexlStrings.ErrTruncatedArgWarning, args[i].ToString(), Name);
continue;
Expand Down
7 changes: 6 additions & 1 deletion src/tests/Microsoft.PowerFx.Core.Tests/TexlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2475,14 +2475,19 @@ public void TexlFunctionTypeSemanticsTimeValue(string script)
[InlineData("Table([1,2], If(1/0<2,[3,4]), [5,6])", "*[Value: n]")]
[InlineData("Table(Sequence(20000))", "*[Value: n]")]
[InlineData("Table(Filter(T1, b = 5))", "*[a:n, b:n, c:n]")]
[InlineData("Table({X:1}, [1, 2, 3])", "*[X:n, Value:n]")]
[InlineData("Table({X:1}, [1, 2, 3])", "*[X:n, Value:n]")]
[InlineData("Table(First(DS), Last(DS))", "*[Id:n, Name:s, Age:n]")]
[InlineData("Table(Last(DS), {count: CountRows(DS)})", "*[Id:n, Name:s, Age:n]")]
public void TexlFunctionTypeSemanticsTable(string script, string expectedType)
{
var symbol = new SymbolTable();
symbol.AddVariable("T1", new TableType(TestUtils.DT("*[a:n, b:n, c:n]")));
symbol.AddVariable("T2", new TableType(TestUtils.DT("*[a:n, b:b, c:s]")));
symbol.AddVariable("T3", new TableType(TestUtils.DT("*[d:n]")));
symbol.AddVariable("T4", new TableType(TestUtils.DT("*[a:s]")));

var dataSourceSchema = TestUtils.DT("*[Id:n, Name:s, Age:n]");
symbol.AddEntity(new TestDataSource("DS", dataSourceSchema));

Assert.True(DType.TryParse(expectedType, out DType type));
Assert.True(type.IsValid);
Expand Down

0 comments on commit 121d1e3

Please sign in to comment.