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

Unifying Remove function with PA #2776

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

Conversation

anderson-joyle
Copy link
Contributor

@anderson-joyle anderson-joyle commented Dec 13, 2024

Issue #2808.

@anderson-joyle anderson-joyle force-pushed the andersonf/unify/remove-function branch from 65b5f6c to 5e675d8 Compare December 13, 2024 19:42
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 13, 2024

✅ No public API change. #Resolved

3 similar comments
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 16, 2024

✅ No public API change. #Resolved

@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 17, 2024

✅ No public API change. #Resolved

@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 19, 2024

✅ No public API change. #Resolved

@anderson-joyle anderson-joyle force-pushed the andersonf/unify/remove-function branch from 4619d74 to 8983927 Compare December 19, 2024 16:32
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 19, 2024

✅ No public API change. #Resolved

1 similar comment
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 19, 2024

✅ No public API change. #Resolved

@anderson-joyle anderson-joyle force-pushed the andersonf/unify/remove-function branch from 9dbde75 to 617a7fd Compare December 26, 2024 20:48
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 26, 2024

✅ No public API change. #Resolved

2 similar comments
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 28, 2024

✅ No public API change. #Resolved

@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 30, 2024

✅ No public API change. #Resolved

@anderson-joyle anderson-joyle force-pushed the andersonf/unify/remove-function branch from 4ea55b9 to 42a16ef Compare December 30, 2024 20:29
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 30, 2024

✅ No public API change. #Resolved

1 similar comment
@LucGenetier
Copy link
Contributor

LucGenetier commented Dec 31, 2024

✅ No public API change. #Resolved

@anderson-joyle anderson-joyle changed the title WIP Remove function Unifying Remove function with PA Dec 31, 2024
@anderson-joyle anderson-joyle marked this pull request as ready for review December 31, 2024 21:28
@anderson-joyle anderson-joyle requested a review from a team as a code owner December 31, 2024 21:28
{
return errorRecord.Error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we should discuss this.

This is eagerly scanning the entire table. Can we confirm that's the language semantics?
The danger is:

  • that could be a lot of work upfront
  • that could prevent future optimizations
  • in paging/delegation cases, we don't download entire table . It could be a random set of rows. If there are error rows, they may or may not show up in that random set.

@LucGenetier
Copy link
Contributor

LucGenetier commented Jan 2, 2025

✅ No public API change. #Resolved

MikeStall
MikeStall previously approved these changes Jan 3, 2025
Copy link
Contributor

@MikeStall MikeStall left a comment

Choose a reason for hiding this comment

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

:shipit:

@anderson-joyle anderson-joyle force-pushed the andersonf/unify/remove-function branch from 236b991 to 9f00032 Compare January 9, 2025 14:41
@LucGenetier
Copy link
Contributor

LucGenetier commented Jan 9, 2025

✅ No public API change. #Resolved

@anderson-joyle anderson-joyle force-pushed the andersonf/unify/remove-function branch from 9f00032 to 1bf13e3 Compare January 19, 2025 21:43
@LucGenetier
Copy link
Contributor

LucGenetier commented Jan 19, 2025

✅ No public API change. #Resolved

return base.TryGetTypeForArgSuggestionAt(argIndex, out type);
}

public RemoveBaseFunction(int arityMax, params DType[] paramTypes)
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] Can you move those function declarations after the constructor for consistency?

If(true, {test:1}, "Void value (result of the expression can't be used).")

>> t4
Table()
Copy link
Contributor

@CarlosFigueiraMSFT CarlosFigueiraMSFT Jan 20, 2025

Choose a reason for hiding this comment

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

Not sure if all of those are covered, but we should have them:

Setup:
ClearCollect(coll, {a:1}, {a:2}, {a:3}, {a:4}, {a:5}, {a:4}, {a:3}, {a:2})

Cases:
Remove(coll, [{a:2}], RemoveFlags.First) // Simple case, First (single element)
-> At the end: 1,3,4,5,4,3,2

Remove(coll, [{a:2}], RemoveFlags.All) // Simple case, All (single element)
-> At the end: 1,3,4,5,4,3

Remove(coll, [{a:2},{a:3}], RemoveFlags.First) // Simple case, First (multiple elements)
-> At the end: 1,4,5,4,3,2

Remove(coll, [{a:2},{a:3}], RemoveFlags.All) // Simple case, All (multiple elements)
-> At the end: 1,4,5,4

Remove(coll, [{a:2},{a:6}], RemoveFlags.First) // Only remove found elements, ignore others, First
-> At the end: 1,3,4,5,4,3,2

Remove(coll, [{a:2},{a:9}], RemoveFlags.All) // Only remove found elements, ignore others, All
-> At the end: 1,3,4,5,4,3

Remove(coll, ForAll(Sequence(5),{a:Value}), RemoveFlags.First) // Match all elements, First
-> At the end: 4,3,2

Remove(coll, ForAll(Sequence(5),{a:Value}), RemoveFlags.First) // Match all elements, All
-> At the end:

Remove(coll, {Value:1}, [{Value:2}])
-> Mixing record and tables should result in a compile-time error

@@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Data;
using System.Linq;
Copy link
Contributor

Choose a reason for hiding this comment

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

Needed?

@@ -3291,21 +3291,41 @@
<comment>function_parameter - Second argument to the Patch function - the updates to be applied to the given rows.</comment>
</data>
<data name="AboutRemove" xml:space="preserve">
<value>Removes a specific record or records from a data source</value>
<value>Removes (optionally All) items from the specified 'collection'.</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

All

all (lower case). We either use the proper enum name ('RemoveFlags.All') or treat 'all' as a common word.

</data>
<data name="ErrRemoveAllArg" xml:space="preserve">
<value>If provided, last argument must be 'RemoveFlags.All'. Is there a typo?</value>
<comment>{Locked=RemoveFlags.All} Error Message, RemoveFlags.All is an enum value that does not get localized.</comment>
</data>
<data name="AboutRemove_collection" xml:space="preserve">
<value>The collection to remove rows from.</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

The collection to remove rows from.

Suggestion: "The collection from which rows are to be removed." This avoid ending a sentence with a proposition.

<value>data_source</value>
<comment>function_parameter - First parameter for the Remove function. The data source that contains the records that you want to remove from. Translate this string. When translating, maintain as a single word (i.e., do not add spaces).</comment>
<data name="RemoveArg1" xml:space="preserve">
<value>collection</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

collection

We can also use Remove to delete items from a connected data source (not only a collection)

<comment>function_parameter - Third argument for the Remove function - value indicating whether to remove all matches or only the first one.</comment>
</data>
<data name="AboutRemove_all" xml:space="preserve">
<value>An optional argument that specifies whether to remove all matches, or just the first one.</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

one

Since we expect it to be a member of the RemoveFlags enumeration, we should list the possible values here (e.g.: An optional argument to specify whether to remove all matches (RemoveFlags.All) or just the first one (RemoveFlags.First).

@CarlosFigueiraMSFT
Copy link
Contributor

#SETUP: PowerFxV1CompatibilityRules,EnableExpressionChaining,MutationFunctionsTestSetup,StronglyTypedBuiltinEnums

The "base" test Remove.txt already defines PowerFxCompatibilityRules, the cases in this file can be merged into the base one.


Refers to: src/tests/Microsoft.PowerFx.Core.Tests.Shared/ExpressionTestCases/Remove_V1Compact.txt:1 in 1bf13e3. [](commit_id = 1bf13e3, deletion_comment = False)

LucGenetier and others added 2 commits January 22, 2025 22:13
Add new connector setting _UseItemDynamicPropertiesSpecialHandling_
Remove _UseDefaultBodyNameForSinglePropertyObject_ as it was not fixing
the issue as expected
Special case handling when
- body name is 'item'
- body inner object is 'dynamicProperties'
- there is only one property in inner object
In that base the body will be fully flattened and we will retain the
'body' name for the parameter.
Address #2751.  
This unifies most of them. To scope this PR, there are subissues on 2751
for remaining issues.



We have a plethora of IAsyncTexlFunction* interfaces. Want to
consolidate on 1, and make it public.

This 
Ttake the parameters on the various IAsyncTexlFunction* overloads and
move them as properties on a new public `FunctionInvokerInfo` class. And
then have a new IAsyncTexlFunction* that takes the invoker. And remove
all the others, migrating them onto this - and fixing the various
bugs/hacks along the way that would impede migration.

Most fundamentally, this FunctionInvokerInfo must have access to
interpreter state and so must live in the interpreter. (Whereas some of
the IAsyncFunction* interfaces live in core).

Successfully removes several here so we get a net reduction, and shows a
path to remove the rest.

This problem quickly touches other problems:
- **How to map from the TexlFunction to the invoker**. This is made more
complicated because we register on PowerFxConfig, but that lives in
Fx.Core and can't refer to interpreter implementations.
- **dll layering around Fx.Json**: Some function implementations live in
Fx.Json, but that specifically _does not_ depend on interpreter (because
it is included by PowerApps).
- **Standard Pipeline**: how to handle default args, common error
handling scenarios, etc. Today, that's still in interpreter. Whereas we
really want those checks to be in the IR and shared across front-ends
(and available to designer).
- **Split up Library.cs and class** - we have one giant class, partial
over many files, containing 100s of function impls. Just give each impl
its own file, similar to how we did for TexlFunction and the static
declarations.
- **lack of unit testing**: Today, most of our interpreter coverage
comes from .txt files. But we should have C# unit tests on interpreter
classes that provide coverage on core classes, like EvalVisitor.

Some related prereq fixes that will directly help here:
- Can we remove runner/context from Join? and leverage LambdaValue -
which already closes over these.
- fix Json layering problem. 
- IsType/AsType _UO shouldn't live in Json. They should work on any UO.
- Remove _additionalFunctions from the serviceProvider.

---------

Co-authored-by: Mike <[email protected]>
@LucGenetier
Copy link
Contributor

✅ No public API change.

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