Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving dependency scan to CORE #2827

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

anderson-joyle
Copy link
Contributor

Issue #2809.

@anderson-joyle anderson-joyle requested a review from a team as a code owner January 22, 2025 22:03
/// The formula "Name & 'Primary Contact'.'Full Name' & Sum(Contacts, 'Number Of Childeren')" would return
/// "contact" => { "fullname", "numberofchildren" }.
/// </example>
public Dictionary<string, HashSet<string>> FieldReads { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

string

I think we will ultimately want to move away from strings.and to something more structured.

@@ -483,7 +483,27 @@ private void VerifyReturnTypeMatch()
/// <summary>
/// Compute the dependencies. Called after binding.
/// </summary>
public void ApplyDependencyAnalysis()
Copy link
Contributor

@MikeStall MikeStall Jan 22, 2025

Choose a reason for hiding this comment

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

ApplyDependencyAnalysis

nit - this is breaking.
Maybe keep old one, add [Obsolete] and point it to new one?
#Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll make the change.

if (!IsSuccess)
{
return null;
}
Copy link
Contributor

@MikeStall MikeStall Jan 22, 2025

Choose a reason for hiding this comment

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

nit - needed? Let ApplyIR() handle this. #Resolved

@@ -19,7 +19,8 @@
using Microsoft.PowerFx.Syntax;
using Microsoft.PowerFx.Types;
using CallNode = Microsoft.PowerFx.Syntax.CallNode;
using RecordNode = Microsoft.PowerFx.Core.IR.Nodes.RecordNode;
using IRCallNode = Microsoft.PowerFx.Core.IR.Nodes.CallNode;
Copy link
Contributor

@MikeStall MikeStall Jan 22, 2025

Choose a reason for hiding this comment

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

IRCallNode

I like the IR prefix to avoid collisions. we should follow that convention more often.
#Resolved

@LucGenetier
Copy link
Contributor

LucGenetier commented Jan 23, 2025

✅ No public API change. #Resolved

// The return value is used by DepedencyScanFunctionTests test case.
// Returning false to indicate that the function runs a basic dependency scan.
// Other functions can override this method to return true if they have a custom dependency scan.
return false;
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

What do these semantics mean? Ie, what is a caller supposed to do differently if we return true vs. false?
#Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed internally.

}
}
else
{
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

Why do we need this logic? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.


public class DependencyContext
{
public bool WriteState { get; set; }
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

bool

can we comment what this fields mean? #Resolved


if (fieldLogicalName != null)
{
var name = Translate(tableLogicalName, fieldLogicalName);
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

name

used? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, from DV side.

public string Translate(string tableLogicalName, string fieldLogicalName)
{
return fieldLogicalName;
}
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

needed? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, from DV side.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, it's virtual now ;)

[InlineData("Min(local,numberofemployees)", "Read Accounts: numberofemployees;")]
[InlineData("Average(local,numberofemployees)", "Read Accounts: numberofemployees;")]

// Patch
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

Test:
Patch(local, First(local), { field1 : First(local).field2 } )

local.field1 is a write.
local.field2 is a read

#Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test case added.

var functions = new List<TexlFunction>();
functions.AddRange(BuiltinFunctionsCore.BuiltinFunctionsLibrary);

var exceptionList = new HashSet<string>()
Copy link
Contributor

@MikeStall MikeStall Jan 23, 2025

Choose a reason for hiding this comment

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

What is the rule what is on this list? #Resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, is this planed for future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment added.

}

// Some functions might require an different dependecy scan. This test case is to ensure that any new functions that
// is not self-contained or has a scope info has been assessed and either added to the exception list or has a dependency scan.
Copy link
Contributor

@MikeStall MikeStall Jan 24, 2025

Choose a reason for hiding this comment

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

or has a dependency scan.

"overrides <see = TexlFunction.ComposeDependencyInfo> #Resolved


public class DependencyContext
{
public bool WriteState { get; set; }
Copy link
Contributor

@MikeStall MikeStall Jan 24, 2025

Choose a reason for hiding this comment

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

set

can these be 'init' instead of 'set'? To emphasize immutability. #Resolved

}
else
{
continue;
Copy link
Contributor

@jas-valgotar jas-valgotar Jan 24, 2025

Choose a reason for hiding this comment

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

continue;

why do we not need to visit this node?
I.e. something like ShowColumns(), can have TextLiteralNode which are column name being used, Are we skipping those? #Resolved

// Set
[InlineData("Set(numberofemployees, 200)", "Write Accounts: numberofemployees;")]
[InlineData("Set('Address 1: City', 'Account Name')", "Read Accounts: name; Write Accounts: address1_city;")]
[InlineData("Set('Address 1: City', 'Address 1: City' & \"test\")", "Read Accounts: address1_city; Write Accounts: address1_city;")]
Copy link
Contributor

Choose a reason for hiding this comment

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

[InlineData("Set('Address 1: City', 'Address 1: City' & "test")", "Read Accounts: address1_city; Write Accounts: address1_city;")]

Can we add atleast 1 test for all functions that uses Table?

ShowColumns(), RenameColumns(), AddColumn(), DropColumns(), Remove() etc...

// Some functions might require an different dependecy scan. This test case is to ensure that any new functions that
// is not self-contained or has a scope info has been assessed and either added to the exception list or has a dependency scan.
[Fact]
public void DepedencyScanFunctionTests()
Copy link
Contributor

@jas-valgotar jas-valgotar Jan 24, 2025

Choose a reason for hiding this comment

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

DepedencyScanFunctionTests

nice test! #Resolved

@LucGenetier
Copy link
Contributor

✅ No public API change.

/// <summary>
/// Compute the dependencies. Called after binding.
/// </summary>
public DependencyInfo ApplyDependencyInfoScan()
Copy link
Contributor

Choose a reason for hiding this comment

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

ApplyDependencyInfoScan

Can we [Obsolete("Preview"] this. I think we'll want to make some changes. Like moving away from strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants