Граф коммитов

1562 Коммитов

Автор SHA1 Сообщение Дата
bryancroteau-MSFT 8c0f5190dd
Initial work on UntypedObject ForAll (#669)
Adds the ForAll function for UntypedObjects. A very bizarre change with
some hacky type checking.

The problem is that overloaded functions with lambdas are not evaluated
bottom-up. This is because some of the arguments may be lambdas. It
leads to a chicken and egg problem: you need to know the override before
you can determine that an argument is a lambda, but you need to know
which arguments are lambdas in order to pick an override.

Thus we enforce that only a single override is allowed to have a lambda.
It is assumed to be a table, and we type check the first argument quite
late.

This implementation piggybacks off of all existing code paths by
"tricking" the type checker into thinking that there is only 1 override.
It will then "switch" the selected override at the last second if it's
discovered that the first argument is an untyped object.

Not ideal for a code maintenance standpoint. However, our other option
is to rename ForAll function to something else specifically for untyped
objects.
2022-09-27 15:31:30 -07:00
Anderson Silva d0f12cac2a
Extra mutation functions test cases based on customers usage. (#686) 2022-09-27 14:20:38 -05:00
sagarbakliwal ebf03d7af0
Fix regression in 'in' delegation for dataverse (#697)
Co-authored-by: Sagar Bakliwal <sbakli@example.com>
2022-09-27 11:58:35 -07:00
bryancroteau-MSFT 5c6ba5d6bc
Add runtime suffix for Index_UO (#692)
Index_UO was implemented before Index, and was implemented incorrectly.
This change adds a runtime suffix for Index_UO.
2022-09-26 13:19:07 -07:00
Luc Genetier 2926ccd0aa
Issue 664 - IGlobalSymbolNameResolver should be an IEnumerable (#688) 2022-09-23 23:11:11 +02:00
Luc Genetier 07eed1bfe1
Add CancellationToken to Collect/Patch/Remove functions (#681) 2022-09-23 18:24:12 +02:00
sagarbakliwal 32cf2e7d1c
Allow lookup field delegation with 'in' operator (#638)
Co-authored-by: Sagar Bakliwal <sbakli@example.com>
Co-authored-by: McCall Saltzman <69215460+lesaltzm@users.noreply.github.com>
2022-09-22 14:15:12 -07:00
Carlos Figueira a463f1d4b9
Fix IsNumeric implementation (#689)
The IsNumeric function should return true for string values that represent, as well as to date, time and date/time values (which has a natural conversion to numbers)
2022-09-22 12:42:22 -07:00
Carlos Figueira f2435aa7b5
Tests for error kinds, move all finite checking to the error handler (#674)
New test to validate error kinds for all functions / operations. Also moved all finite checking to the function wrapper instead of having each function declare it
2022-09-22 11:43:42 -07:00
Carlos Figueira 6924361417
Move numeric tests to ready state, fix bug in Average function (#682)
Moving more tests to the ready state (numeric functions). Fixed bug in Average function when dealing with error rows
2022-09-20 11:29:57 -07:00
Anderson Silva 8bbd30f978
Bug 15575103: C#: ForAll doesn't handle error records correctly (#680) 2022-09-20 09:18:58 -05:00
Carlos Figueira 2b33fc9ca4
Check invocation result fail prior to get tabular result (#678)
A recent change caused an exception to be thrown if an invalid tabular DateAdd function was used. This fixes it and adds a new test to check this scenario.
2022-09-17 20:29:49 -07:00
Joris de Gruyter 81daa74b9f
Assign default value to properly initialize coercionDifference (#676)
resolves #675
2022-09-16 11:11:31 -07:00
Carlos Figueira bf0c938510
Updated single table wrapper to use the wrapped scalar function (#624)
Currently some of the tabular versions of scalar functions are not calling the scalar version properly - instead of going to the function as exposed to the user (the wrapper that handles errors and blank values), it is going to the inner implementation. This PR updates the tabular versions for single argument functions (multi-argument functions will come later).

This also fixes the Char function to treat Blank values as 0, like Excel does.
2022-09-16 10:40:29 -07:00
Carlos Figueira 528b8d9a13
Fixes for Date/time operations and functions (#659)
This PR moves more date/time-related tests from the "notYetReady" folder
to run, and fixes a bunch of issues with date/time operations and
functions:
- Adding / subtracting numbers to date values now honors the fractional
part of the numbers (and the resulting type is DateTime)
- Similar fix for the DateAdd function with Date values
- Fixed time difference (timeValue1 - timeValue2)
- Allowed the addition of DateTime and Time values
- Allowed the addition of Time values
- Allowed the subtraction of time values from date[time] values
- Fixed Time function with overflows
2022-09-16 09:22:05 -07:00
Greg Lindhorst 7a1e957e0f
Update UDF syntax (#671)
Update UDF syntax:
- Equal for one expression formulas, consistent with named formulas
- No operator (no equal or double barrel arrow) for block functions
enclosed in curly braces, consistent with C-like languages
2022-09-15 19:29:04 -07:00
Carlos Figueira 6823a07d37
Enabled tests that were skipped (#667)
We have a few tests that are marked as skipped, but can run
successfully, so removing their #skip annotations. This also fixes blank
value comparison (and removes skipped tests for that).
2022-09-15 18:36:22 -07:00
Kartik K R 88b4fd9823
Fix delegation warning to be only if Async Nodes when In operator is used. (#670)
A recent change to prevent delegation of Filter(TableA.Optionsetcolumn
in multiselectOptionset) (https://github.com/microsoft/Power-Fx/pull/522
) regressed a delegable scenario for singleSelectOptionSet in Collection
to be non delegable, adding an explicit check to not delegate if the in
operator is used on a async node instead of checking for !IsAggregate.

TestCases added in Client repo

Co-authored-by: Kartik K R <karr@microsoft.com>
Co-authored-by: McCall Saltzman <69215460+lesaltzm@users.noreply.github.com>
2022-09-15 13:52:21 -07:00
Luc Genetier 67476d0ba6
Fix error message when record to record coercion might be needed (#666)
Such expression requires record to record coercion which wasn't
implemented
Patch(Table2, Lookup(Table2,
Table2=GUID("802dcedc-492f-ed11-9db2-0022482aea8f")), {MyDate:
"2022-9-14 7:11:04 pm" })

Before this fix, the error message we were returning was "unknown
error", now, it will provide a clear error message, asking for MyDate to
be a DateTime and not a string.
2022-09-15 21:35:34 +02:00
Mike Stall 40a76b1858
Support extensible CodeFixes. (#653)
Support extensible CodeFixes. 
Introduce a new class, EditorContextScope , to implement IPowerFxScope.
This lives in LSP.

Introduce new interface to supply code fix handlers:
```
    public interface ICodeFixHandler
    {
        Task<IEnumerable<CodeActionResult>> SuggestFixesAsync(
            Engine engine,
            CheckResult checkResult);
    }
```

And set:	
```
	var scope = engine.CreateEditorScope(symbols);
	scope.AddQuickFixHandler(new MyCodeFixHandler()); // ICodeFixHandler
	// return scope to IPowerFxScopeFactory
```
	

[0] Made RecalcEngineScope and supercede with a EditorContextScope.
Obsoleting this because:
- it creates an unnecssary dependy on RecalcEngine, instead of just
working with Engine class.
- hence lives in interpreter, when it should be in LSP.
- superseded by EditorContextScope, which has more editor
customizations.
- encourages a strong coupling on FromJson; but context is not json. 

[1] CheckResult should have closure of its input args and serve as an
abstraction over the parse/bind results.
- add original parser text to CheckResult so that we don't have to pass
(expression,CheckResult) around.
- add Symbol table. internally, the Binding holds an INameResolve, so
it's consistent for CheckResult to hold the symbol table.

	- input expression
	- extra symbols  (~binder has the INameResolver that it used)

This was useful in simplifying signatures. Then we can just do:

public IIntellisenseResult Suggest(CheckResult checkResult, int
cursorPosition)


[2] add ReadOnlySymbolTable.SymbolNames  ?? *** rename , match to names?


[3] Expose some more spans, like Identifier.Span - which can be useful
in writing refactorings. *** as property

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2022-09-14 14:08:25 -07:00
Vamsi Modem 2654fec556
Added GetTableNodes() to binder (#668)
As a part of the feature I am working on , I need to modify the script
as below for all the tables, for that I will need all the table nodes.
`[{a: 1}, {a: 2}] -> [{value: {a:1}}, {value: {a:2}}]`
2022-09-14 11:51:27 -07:00
Anderson Silva 2e36ee2fc4
Adding GetInvariantExpression tests to mutation funtions. (#665) 2022-09-14 13:06:34 -05:00
Anderson Silva 58b9731243
Converting in-memory table into mutable object for mutation functions. (#661)
Enables mutable semantics immediately, Need to find some way to optimize in a future PR.
2022-09-13 12:48:10 -05:00
Anderson Silva 02ca3a3d0c
Mutation functions follow-up changes (#649)
Fixes/changes to #611.
2022-09-13 10:01:06 -05:00
Jas Valgotar 8eb63da5a0
Fixes #647 Crash for ForAll with two fields (#654)
-Fixes #647 
-Added test for the issue as well.
2022-09-12 10:30:16 -04:00
Mike Stall b586a2ea12
Fix crash in enumbuilder. (#650)
If the config has a chained symbol table:

powerFxConfig.SymbolTable = new SymbolTable() { Parent =
dataverseConnection.Symbols };

Then expressions like this get a null ref:
(IEnumStore) config.EnumStoreBuilder.Build(),

because config.EnumStoreBuilder is just
config.SymbolTable.EnumStoreBuilder, which is null.

It's not enough to just initialize SymbolTable.EnumStoreBuilder to
non-null, we need to ensure the symbols are actually composing.

This runs all Suggest tests in both configurations.

Marking config.EnumStoreBuilder as obsolete.
PowerApps doesn't call config.EnumStoreBuilder.
Dataverse does, but those call should config.EnumStore instead.

This was related to #503.

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2022-09-11 11:01:38 -07:00
Sunnie So 93685cb3b1
Add tests for custom record type that allows access to undefined fields (#626)
By default, Power FX is strongly + static typed. References to any
undefined fields will result in error state at type checking time.

This set of unit tests gives an example which overrides that behavior by
writing a custom `RecordType`, which always returns
`FormulaType.UntypedObject` from `TryGetField()` when the targeted field
is not defined.

Assume an expression `"obj.field1"`. If field1 is not defined, by
default it will throw at `Check()`. With this change, it will pass type
checking, and result in `BlankValue` (but of `UntypedObject` type)
during runtime.
2022-09-09 15:11:10 -07:00
bryancroteau-MSFT 615da90c32
Change ErrorContainer to IErrorContainer in BinderUtils (#648)
Dataflow Analysis uses IErrorContainer instead of ErrorContainer. The
Binder utils does not need to use anything on the concrete class. So we
use the interface instead.
2022-09-09 14:48:02 -07:00
Carlos Figueira 99af4f1d2e
Treat blank as false in Boolean operators (#641)
Blanks are currently treated as "false-y" values Boolean operators (Or, And), but not exactly false - there are some cases where blanks are returned (e.g., And(Blank(), true)). This PR changes the operators behavior so that the results of the expression above will be false.
2022-09-09 14:13:46 -07:00
Carlos Figueira ac3650a03e
Fix description for the DateTime function (#646)
The description for the DateTime function is incorrect, this fixes it.
2022-09-09 14:03:50 -07:00
Anderson Silva d390546409
Implement ICollection to DataTableWrapper (#640)
For #637
2022-09-08 15:39:45 -05:00
Luc Genetier af44a42d4f
IR translator update - don't add unneeded AggregateCoercionNode (#642)
EvalVisitor is not implemented on AggregateCoercionNode for records, but
the coercion matrix frequently produces this node in expressions like
'Patch(MyTable, { Currency: 1.2 }, { Currency: 1.5 })' when the Currency
column is a DType.Currency.

We should eventually implement RecordToRecord coercion, but as a first
stop, don't emit this coercion node if there actually aren't any
coercions used
2022-09-08 22:26:54 +02:00
Luc Genetier 26d263f3c4
Add HasField method (#644) 2022-09-08 21:46:39 +02:00
McCall Saltzman 3436202cf2
Revert #465 conditioned on flag (#634)
Partially Reverts #465 which introduced a significant performance
regression.
This change reverts it, conditioned on a new flag added to
DocumentProperties. We'd like to remove this flag, and will once we've
adjusted the core Select/Expand behavior.
2022-09-08 10:11:30 -07:00
Carlos Figueira 2f452574c8
Move D* tests from NotYetReady to Ready (#636)
Continuing to move tests from the "NotYetReady" folder to the place
where they can actually run. Files starting with D. This is also fixing
some issues in the interpreter:
- DateDiff was not honoring date part boundaries
- Proper handling of blank values in DateAdd/DateDiff/Date functions
- Fix bug with DateAdd/DateDiff across daylight saving time boundaries
- Better errors for invalid dates
2022-09-07 21:22:09 -07:00
Mike Stall ec7f313c67
Better way to solve #631 (better than #635) (#639)
Binder can handle it automatically if flags are set properly. This also
imposes the same restrictions as powerapps.
Better way to solve #631 (better than #635)
2022-09-07 18:01:45 -07:00
Anderson Silva a2b40ff962
Remove function phase 1 (#633)
Phase 1 for [**Remove( DataSource, Record1 [, Record2, ... ] [, All
]
)**](https://docs.microsoft.com/en-us/power-platform/power-fx/reference/function-remove-removeif#syntax)
implementation.
2022-09-07 18:02:28 -05:00
Anderson Silva d55a25eca8
Patch function implementation (#627)
Co-authored-by: Luc Genetier <lucgen@microsoft.com>
2022-09-06 16:00:52 -05:00
McCall Saltzman 1ce8f437a6
Mark IExternalEnabledFeatures as internal (#632)
This IExternal was incorrectly exposed on the public surface, but is not actually usable by any non-internal hosts, all the places it would be used are already `internal`. Thus, we think it's safe to make this breaking change.
2022-09-06 12:09:43 -07:00
Luc Genetier dd90f041aa
Make NotDelegableException public (#630) 2022-09-05 18:57:34 +02:00
Carlos Figueira a38e155bf8
Treat blank inputs to the Sequence function as zeros (#622)
Blank values should be treated as 0 when passed as the input to functions in numeric contexts. Currently the Sequence function doesn't do that, and this PR fixes it.
2022-09-02 12:50:35 -07:00
bryancroteau-MSFT c0da7730ff
Refactor and move binder code to BinderUtils (#621)
Clean up, rename, and move Binary and Unary node binder code into BinderUtils.
2022-09-02 11:15:46 -07:00
Jas Valgotar 7eaeffc3c9
Intellisense shouldn't suggest Table.Columns Fixes #561 (#620)
-Fixes #561 
-Removed Intellisense from Table type.
-Added new tests to verify.

Co-authored-by: Mike Stall <mikestall@hotmail.com>
2022-09-02 10:03:39 -05:00
bryancroteau-MSFT 363e79df6a
Make outstanding binary op node dependencies more functional (#613)
CheckEqualArgTypes
CheckComparisonArgTypes
CheckComparisonOneOf

These functions are all used by the PostVisit method for Binary op nodes and need to be made functional.

Also makes the PostVisit functions for both Binary and Unary op nodes more functional.
2022-09-01 16:30:28 -07:00
ivanradicek ecc513fdb8
Make `TexlNode.Parent` public (#609)
This property is made read-only public, similar as in [Roslyn's SyntaxNode](https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.syntaxnode.parent?view=roslyn-dotnet-4.2.0#microsoft-codeanalysis-syntaxnode-parent).
2022-09-01 15:15:15 -07:00
Jas Valgotar 03bb8ac1ed
Updates TryGetFieldType to check for null/empty DNP (#619)
-Updates TryGetFieldType to check for null/empty DNP in-case derived types did not provide DisplayNameProvider.
2022-09-01 16:37:53 -05:00
Carlos Figueira a2e891f001
Move B*,C* tests from NotYetReady to Ready (#618)
Continuing to move tests from the "NotYetReady" folder to the place where they can actually run. Files starting with B, and C. Also update how time values are compared in test results.
2022-09-01 14:14:46 -07:00
Luc Genetier 98913ea752
Make ODataParameters members visible and rename ODataParams to ODataParameters (#617)
Co-authored-by: Mike Stall <mikestall@hotmail.com>
2022-09-01 21:32:37 +02:00
Luc Genetier b272007a47
Fix symbols generation (#606) 2022-09-01 21:16:50 +02:00
Mike Stall 8b0f411ba1
Port TexlTest.cs to FxCore. (#615)
This started failing with #610.

Note in debug tests, we hit an Contract assert in binder in _binding.ResultType.

In PAClient, it uses retail FxCore, so contracts are disable, and hence we fail in
2022-09-01 11:36:39 -07:00