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

1369 Коммитов

Автор SHA1 Сообщение Дата
Adithya Selvaprithiviraj bd033f54ee
Validate type literal parse (#2402)
Since we use generic expression parser for parsing type expression
within type literal node, we consider an expression like `Type(5+5)` to
be parsevalid.

This PR 
1. Adds a validator to allow only valid type expressions.
2. Simplifies `DTypeVisitor` to use `DefaultVisitor` 
3. overrides exception when visiting `Type(Type(..))`
4. Adds TexlPretty for `TypeLiteralNode` to enable ToString.
2024-05-16 16:45:05 -07:00
Carlos Figueira d5cfbacfc2
Update resource lock directive per request from the localization team (#2413)
The localization team asked us to update the locked directive for one
resource, as it was having errors in a few languages.
2024-05-16 15:30:42 -07:00
Mike Stall 76fe4bc303
stronger typing to help with #2406. (#2407)
See #2406. This doesn't fix issue, but makes types more strongly typed
to help reduce the window.

Avoid mutable fields.
2024-05-16 18:44:59 +00:00
toshio-msft 247b87eda2
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240516-154643-q0pkhh0qj] (#2409)
Translation handback check-in (PR Created by automation).
2024-05-16 09:16:49 -07:00
Luc Genetier f1afe8c523
Tabular connector refactoring (#2404)
no swagger
no v2
add ConnectorDataSource
get Dataset Metadata
2024-05-15 08:30:24 -07:00
Anderson Silva ebe58cf32a
Summarize should have a compile time error for Identifier as Name (#2395)
Issue https://github.com/microsoft/Power-Fx/issues/2370.
2024-05-14 13:39:26 -07:00
Carlos Figueira 8d5e598280
Add tests specific for the Decimal and Float functions (#2398)
There are no tests specifically for those functions; this splits the Value tests and adds those.
2024-05-13 16:27:48 -07:00
Luc Genetier 24db8995fa
Update codeowners (#2399)
Add power-fx-project-reviewers group to review .csproj and .sln files
2024-05-13 20:39:01 +00:00
McCall Saltzman f165db0f18
Update Invalid Use of Dot error (#2396)
Updates error to "The '.' operator cannot be used on <TypeName> values"

The error shows up in the case of
"the thing on the left of “.” is a number/string/other thing you can’t
use “.” on ever, excluding polymorphic because it's weird"
2024-05-10 14:11:34 -07:00
Mike Stall 9495a9fb51
Add more guards against threading misuse and races. (#2389)
Add more guards against threading misuse and races.
No functional changes.
2024-05-10 18:26:31 +00:00
Anderson Silva e7706f54e0
Adding VISION to README.md (#2391) 2024-05-10 15:13:58 +00:00
Greg Lindhorst ebf7e94da8
More improvements to strongly typed option sets (#2390)
Addresses customer reported bug in pre-V1 where option set value =
Blank() resulted in an error. General remedy is to return the pre-V1
code to its original state and have a large if around V1 vs. pre-V1
code. And more tests.
2024-05-10 07:45:56 -07:00
Carlos Figueira 75003651c1
Moved test from Rand.txt that depended on number being decimal (#2379)
One test from Rand.txt assumes that numbers are decimal; this moves it to a separate file.
2024-05-10 13:18:33 +00:00
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