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

1556 Коммитов

Автор SHA1 Сообщение Дата
jack-work 0b9c6aad6b
Proper Target Relationship in AddRelatedColumns Public Method (#2381)
The other methods in the query options classes use the datasource
associated with the target relationship to resolve relationship
metadata, where AddRelatedColumns uses the parent datasource, which
refers to the source datasource (e.g.
SourceDatasource.TargetDataSourceRelatedColumn.Name). This PR fixes
that.
2024-05-09 17:41:28 -07:00
Greg Lindhorst ac9125dd07
Fix strongly typed option sets issues in Power Apps (#2382)
Option sets coming from Dataverse that are backed by a number are not
handled correctly in Power Apps, a pre-V1 host. An error is produced for
comparisons where there was not one previously. A few checks for pre-V1
were missing:
- Concatenate function (but not the operator)
- Numerical comparisons between option sets

Updating the test suite revealed that the interpreter's implementation
of Concatenate didn't properly account for non-string option sets, which
has also been fixed.

One reason we didn't detect these problems earlier is that we use
EnumSymbol as a proxy for OptionSet, which is usually pretty good, but
in the comparison case it led tests to fail but the product to fail.
There will be a separate task to expand OptionSet to support more data
types and update the tests.
2024-05-09 14:57:44 -07:00
Adithya Selvaprithiviraj 9910b63550
Introduce User defined named types (#2361)
Step 4 of allowing user defined types effort.

Adds ability for users to define named types and use it in
UserDefinedFunction.

For example,
```
// Record Type
Point = Type({ x : Number, y : Number});

distance(a: Point, b: Point): Number = Sqrt(Power(b.x-a.x, 2) + Power(b.y-a.y, 2));

// Table Type
Points = Type([Point]);
Numbers = Type([Number]);

// Type Alias
Name = Type(Text);
```
`AllowParseAsTypeLiteral` can be used in the expression parser to parse
inline type definitions as `TypeLiteralNodes`
2024-05-09 11:33:56 -07:00
Adithya Selvaprithiviraj 8e0628d189
Fix UDF with invalid body to be ParseInvalid (#2377)
We considered UDF with parse failures in body to be parse valid UDFs
which leads to issues when binding the body of UDFs with errors.

In This PR we check if there are any new errors after parsing body and
set parseValid appropriately.
2024-05-07 11:55:48 -07:00
Luc Genetier 3581c30fea
Rename CdpSwaggerTabularService and remove PowerFxConfig in InitAsync (#2375)
Rename CdpSwaggerTabularService to ConnectorTable
Remove PowerFxConfig in InitAsync
2024-05-06 16:12:13 -07:00
Mike Stall db99a5ea40
Add extra guard to protect symbol table (#2369)
Caller is responsible Symbol tables shouldn't be mutated while they're
being read.
See #1551 for details on rule about threading. 

This doesn't fix the problem, but gives us a better (and more
deterministic) exception when it happens.


Possibly related to tracking down #2136
2024-05-04 00:45:34 +00:00
Luc Genetier 9b3330d5b8
Fix connector function when returning a blob (#2368)
When a connector function was supposed to return a BlobValue, we were
returning a string instead.
2024-05-03 17:38:20 +00:00
Anderson Silva 4f6ba37437
Adding Suggestions to releasenotes-1.3.0-rc.md (#2367) 2024-05-02 18:24:51 -07:00
Anderson Silva 75d35e153f
Adding Summarize to releasenotes-1.3.0-rc.md (#2366) 2024-05-02 19:26:11 -05:00
Anderson Silva 9b2185e9b5
Suggestions pseudo function (#2365)
Issue #2313.


![image](https://github.com/microsoft/Power-Fx/assets/19541904/24e324e3-234e-460c-96f1-831bd297d84d)
2024-05-02 16:53:58 -07:00
Anderson Silva c7a5af75ce
Summarize function (#2317)
Issue https://github.com/microsoft/Power-Fx/issues/2301.

---------

Co-authored-by: Greg Lindhorst <gregli@microsoft.com>
2024-05-02 17:18:14 -05:00
toshio-msft 0269ad8f04
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240502-164759-02vvr0kdh1] (#2364)
Translation handback check-in (PR Created by automation).
2024-05-02 17:08:34 +00:00
Luc Genetier 3e9785f89b
Revert "Fix TryGetDsInfo for FirstNameNode, when using a variable (#2… (#2363)
…352)"

This reverts commit b314420bb8.
2024-05-02 08:39:47 -07:00
Luc Genetier b314420bb8
Fix TryGetDsInfo for FirstNameNode, when using a variable (#2352)
There are 3 fixes in this PR
1. in TryGetDsInfo, if FirstNameNode is a variable, we were not
returning IExternalDataSource value. We now search in the symbol table
for the variable corresponding type to get it. There is no direct test
in this repo, this only impacts DV repo where another bug shows up (see
below)
2. in PostVisit for AsNode. In CheckAndMarkAsPageable we could set
stateful flag to true (line 1227) while reseting the flag at line 3933.
3. in IsBlankFunction, IsRowScopedServerDelegatable was not considering
DottedNameNode
2024-05-02 13:29:05 +02:00
Mike Stall 9f597a4974
Delegation interfaces (#2360)
1. add delegation interfaces into fx.core so that other libraries can
begin to delegate to TableValue.
2. make ConnectorTableValue implement these. 
3. switch to use IReadOnlyCollection . This is a) readonly, b) has a
count . Count is important to emphasize that this is not delay execution
- because we make a network call, we need to ensure the call happens
upfront.
2024-04-30 22:08:56 +00:00
Greg Lindhorst d3266e8b97
Update Mod and RandBetween type handling (#2355)
From a type perspective, Mod should act like / (division). The arguments
should be symmetric with a Decimal result only if both arguments are
Decimal. This is not the case, there is a bug here where the first
argument is dictating the result of the function alone. The same holds
for RandBetween which has the same problem. This PR fixes both functions
and adds many tests.

Here, the second result should be 1 with no decimal as the calculation
should be done in Float.
```
>> Mod( 3.0000000000000000000003, 2.0000000000000000000002 )
1.0000000000000000000001

>> Mod( 3.0000000000000000000003, Float(2.0000000000000000000002) )
1.0000000000000000000003

>> Mod( Float(3.0000000000000000000003), 2.0000000000000000000002 )
1

>> Mod( Float(3.0000000000000000000003), Float(2.0000000000000000000002) )
1
```

Likewise, RandBetween has the wrong answer for the second case, where
the second argument is coerced to a decimal (while losing digits).
```
>> 
>> RandBetween( 12345678912345678912345678, 12345678912345678912345678 )
12345678912345678912345678

>> RandBetween( 12345678912345678912345678, Float(12345678912345678912345678) )
12345678912345697471862876

>> RandBetween( Float(12345678912345678912345678), 12345678912345678912345678 )
1.2345678912345679E+25

>> RandBetween( Float(12345678912345678912345678), Float(12345678912345678912345678) )
1.2345678912345679E+25
```
2024-04-30 13:30:22 -07:00
Mike Stall 10c68c12bb
fix batch file (#2359)
Use NUGET_PACKAGES environment variable if set.
2024-04-30 10:46:02 +02:00
Adithya Selvaprithiviraj f366046f70
Introduce NamedTypes to INameResolver (#2350)
Step 3 of allowing user defined types effort .

* Introduces NamedTypes, LookupType in INameResolver. 
* Remove PrimitiveTypeSymbolTable usage, and use NamedTypes from Engine
Symbols
* Require INameResolver to create UDFs.
* Removes `TypeSymbolTable`, `PrimitiveTypesSymbolTable` and
`DefinedTypeSymbolTable`

This will be followed with

1. Introduce parsing and adding user defined NamedTypes.
2. Optimize type graph to update incremental.
2024-04-29 16:12:22 -07:00
Mike Stall 4a9f9e996d
Fix #2241. (#2339)
Fix #2241 - adds a TryGetType to lookup a variable by name (very useful
when it doesn't have a slot) and return its type.

This is particularly interesting for enums/optionsets - which don't have
slots (since they don't have per-eval storage). But
beware , #2342 - some of the FormulaTypes for enums/optionsets are not
correct.
2024-04-29 14:44:45 +00:00
Luc Genetier 8b2e737c72
Add table and column capabilities to tabular connectors (#2348) 2024-04-29 14:54:19 +02:00
Akshar feb4c790e2
Don't throw System Not Implemented Error (#2353) 2024-04-26 13:05:21 -04:00
Luc Genetier 8545d01521
Fix intellisense with Collect function and records (#2331)
Resolves issue https://github.com/microsoft/Power-Fx/issues/2326
2024-04-26 17:31:09 +02:00
McCall Saltzman cb71463192
Ensure EnsureError returns error (#2351) 2024-04-25 13:24:03 -07:00
toshio-msft 5b78d154c0
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240425-193109-g2rpb964s6] (#2349)
Translation handback check-in (PR Created by automation).
2024-04-25 19:51:17 +00:00
Adithya Selvaprithiviraj 6fec6a2e65
Retire ProcessUserdefinitions (#2345)
Step 2 of allowing user defined types effort .

Retires `UserDefinitions.ProcessUserdefinitions` as it creates a tight
coupling between Parse and processing of all different kinds of
Userdefinitions.

We and our tests assume that client uses this method for processing,
hence fixing all the tests as we will not use this moving forward.

Moving `AllowAttributes` transformation to `Parse` as it is a
transformation of `ParseResult` and returns a `ParseResult` . Ideally
this could be a transformation on NamedFormula `ParseResult` .

This will be followed with  

1. Introduce NamedTypes, LookupType in INameResolver but support only
Primitives. Remove PrimitiveTypeSymbolTable usage , Require
INameResolver to create UDFs.
2. Introduce parsing and adding user defined NamedTypes.
3. Optimize type graph to update incremental.
2024-04-25 10:07:09 -07:00
Carlos Figueira 4c75250925
Removed resource that should not be translated (#2347)
We have a string that is a fwlink redirector in our localized resources. Fwlinks should not be translated (it redirects to the user locale, based on the browser's language), so this change removes it.
2024-04-24 23:44:25 +00:00
Carlos Figueira 4ad7eef7e1
Propagate display names with ShowColumns (#2346)
Now that ShowColumns can be used with display names, we should propagate the name mapping so that its output also has both logical and display names.
2024-04-24 15:40:11 -07:00
Luc Genetier 3c899d0c71
Intellisense: fix duplicate key exception in expression converter (#2328)
Fix #2325
2024-04-24 17:58:43 +02:00
Jas Valgotar 1383a52d68
Adds a way Hosts can add error without extending Engine. (#2341)
Hosts can now add custom host specific authoring error without extending
the Engine class.
2024-04-24 00:16:31 +00:00
Adithya Selvaprithiviraj 4b650d96dd
Refactor CreateUserDefinedFunctions (#2340)
Minor refactor as a part of introducing user defined types effort.
* Moved private method CreateUserDefinedFunctions from UserDefinitions
to UserDefinedFunction and exposing it to hosts. With this hosts can
create IR UserDefinedFunction from parser UDF result without being
tightly coupled with NamedFormulas or user defined types.
* This will help in introducing Userdefinedtypes . Userdefinedtypes
should be processed and resolved first before creating UDF IR as
argTypes should be known.


This will be followed by

1. Retiring `UserDefinitions.ProcessUserDefinitions` - this method
simply parses UserDefinition script and creates UDF IR and NamedFormula
ParseResult
2. Introduce NamedTypes, LookupType in INameResolver but support only
Primitives. Remove PrimitiveTypeSymbolTable usage , Require
INameResolver to create UDFs.
3. Introduce parsing and adding user defined NamedTypes. 
4. Optimize type graph to update incremental.
2024-04-23 16:03:17 -07:00
Carlos Figueira 2b5a08320c
Require Power Fx 1.0 for the Decimal function (#2338)
When we enable the Decimal function in Power Apps, we will only do that for apps that select Power Fx 1.0. This makes it a compile-time error to try to use the function without it.
2024-04-23 13:01:25 -07:00
McCall Saltzman 7170ba3409
Avoid nullref in ErrorContainer (#2335)
This fixes a nullref that's always been possible in
ErrorContainer.HaserrorsInTree Following #2284 it was more common that
errors had only a token and not a node. This wasn't handled in this
function.
2024-04-22 20:37:40 +00:00
Greg Lindhorst 79c3ff2fda
Adding decimal tests translated from DotNet (#2333) 2024-04-22 08:19:36 -07:00
Luc Genetier bca6722e4f
Add SalesForce CDP tabular test (#2332) 2024-04-20 23:37:14 +02:00
rick-nguyen 147baead4d
Supporting curly braces when declaring UDFs (#2294)
Initial PR to support imperative logic and chained expressions in UDFs.
2024-04-19 07:39:01 -07:00
Luc Genetier 008e6fd575
Fix DisplayName logic in connectors (#2329) 2024-04-18 15:55:54 +00:00
Luc Genetier 1527d7e836
Connectors: Avoid conflicts in display names (#2324) 2024-04-17 15:29:19 +00:00
Greg Lindhorst 22c1f71837
Strongly typed enums for function parameters (#2283)
Adds additional flags for semantic control of individual option sets.
See the comments at the top of IExternalOptionSet.cs and the comments
and test cases in StronglyTypedEnum_*.txt files.

Note that this does not impact Enums, at this point only used by Canvas
apps.
2024-04-16 23:16:22 +00:00
Greg Lindhorst 9f9c7f17bc
Only run CheckSemantics if CheckTypes passes (#2292)
We are producing some additional errors that we don't need, that either
don't add any value or can be confusing.

For example
```
>> ClearCollect(Float(1)/0,Foo)
Errors: Error 24-27: Name isn't valid. 'Foo' isn't recognized.|Error 21-22: Invalid argument type (Number). Expecting a Table value instead.|Error 21-22: The value passed to the 'ClearCollect' function cannot be changed.|Error 0-12: The function 'ClearCollect' has some invalid arguments.
```
The third error about the value cannot be changed, although technically
correct, is not adding any value as there are much bigger issues here.
It comes from CheckSemantics, which doesn't need to be run if we already
have errors from CheckTypes.
2024-04-16 22:05:06 +00:00
Akshar 3d61d37b92
Heavily Refactor LSP (Still Backwards Compatible) and Make it Async and Customizable (#2308)
This pr significantly refactors LSP SDK to truly make it async and bit
customizable. This pr also reorganizes existing tests into a much
modular structure while still keeping around the old tests as a proof
that the changes in this pr are backwards compatible.

The main goal of this PR is to make LSP async in such as a way that
hosts can run expensive operations like nl2fx network calls
asynchronously while making sure the operations that need to run
synchronously acquire correct host specific locks.

This pr accomplishes it goals by 
1) Refactoring a monolith language server class into small handlers
targeting only one specific method. Each handler is async by default and
this allows us to not let LSP block threads inside its hosts
2) LSP in this pr identifies critical sections which are delegated to
hosts for their executions. Host provides an environment using which LSP
can acquire appropriate locks and run those critical sections inside
Host environment
3) LSP, now being async, allows hosts to run Nl2Fx or Fx2Nl network
calls in a non blocking way
2024-04-16 15:53:46 -04:00
Luc Genetier 0746c26542
Tabular Connectors - Rework SwaggerTabularConnector and various fixes (#2323)
Rework SwaggerTabularConnector function identification logic
Remove all hardcoded names (table, default...)
Rename DataSetName to DatasetName
Add GetGlobalValueNames which returns the list of expected global value
names
Move OpenApiDocument to constructor
Better detection of missing global values
CdpTabularConnetor: add Name and DisplayName (only valid after Init)
ConnectorType: Fix DisplayName and add Summary
Add SalesForce tests
2024-04-16 21:26:03 +02:00
Adithya Selvaprithiviraj ad6e3c2166
Fix incorrect warnings from Table function (#2322)
Table function gives incorrect warnings in cases like

```
With({majors: Filter(DS, Age >= 18)},Table(majors,{Id:0, Name: \"Other\", Age:100}))
```

this PR addresses this issue.
2024-04-15 20:55:19 -07:00
Luc Genetier 77d28148bd
Tabular connectors: Add support for SalesForce and clean code (#2319) 2024-04-15 20:11:53 +00:00
Jas Valgotar fad24bac90
Fixes a null ref in Intellisense (#2321) 2024-04-15 19:51:34 +00:00
Carlos Figueira 11c963e22d
Update function parameter resource comments to instruct that resources should be localized (#2316)
Based on feedback from the localization team, resources that contain `_` are typically not localized. This updates all function parameters which contain those with explicit instructions to localize them.
2024-04-15 12:32:07 -05:00
toshio-msft e9d40deade
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240410-211903-d2w1kr1s86] (#2314)
Translation handback check-in (PR Created by automation).
2024-04-10 14:47:56 -07:00
Luc Genetier 6bfd5c3282
Tabular connectors - initial work (#2306) 2024-04-10 20:42:03 +02:00
Luc Genetier ed83c6709c
Detect when a body has multiple parameters and when one of them is blob (#2311)
This is a particular condition we don't support and should detect

Otherwise we end up with this exception

![image](https://github.com/microsoft/Power-Fx/assets/69138830/b65339dd-ec73-45c7-ae60-a20d61612043)
2024-04-09 16:21:19 +02:00
Anderson Silva b736d9a8fd
Binder should suggest based on "AllowSideEffects" (#2307)
Issue https://github.com/microsoft/Power-Fx/issues/2304.
2024-04-04 16:02:29 -05:00
toshio-msft 8da028978d
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240403-215834-1qje2my144] (#2305)
Translation handback check-in (PR Created by automation).
2024-04-03 22:20:31 +00:00