Skip to content

Commit

Permalink
Merge branch 'main' into andersonf/join-function
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-joyle authored Nov 4, 2024
2 parents 3ce5033 + ae733a6 commit c62088c
Show file tree
Hide file tree
Showing 105 changed files with 21,117 additions and 366 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ internal sealed class ServiceCapabilities : IColumnsCapabilities
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public readonly GroupRestriction GroupRestriction;

[JsonInclude]
[JsonPropertyName(CapabilityConstants.FilterFunctions)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public readonly IEnumerable<string> FilterFunctions;

public IEnumerable<DelegationOperator> FilterFunctionsEnum => GetDelegationOperatorEnumList(FilterFunctions);

[JsonInclude]
[JsonPropertyName(CapabilityConstants.FilterFunctionSupport)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand Down Expand Up @@ -115,12 +108,11 @@ public ServiceCapabilities(SortRestriction sortRestriction, FilterRestriction fi
Contracts.AssertValue(pagingCapabilities);

SortRestriction = sortRestriction;
FilterRestriction = filterRestriction;
FilterFunctions = filterFunctions;
FilterRestriction = filterRestriction;
PagingCapabilities = pagingCapabilities;
SelectionRestriction = selectionRestriction;
GroupRestriction = groupRestriction;
IsDelegable = (SortRestriction != null) || (FilterRestriction != null) || (FilterFunctions != null);
IsDelegable = (SortRestriction != null) || (FilterRestriction != null) || (FilterSupportedFunctions != null);
IsPagable = PagingCapabilities.IsOnlyServerPagable || IsDelegable;
SupportsDataverseOffline = supportsDataverseOffline;
FilterSupportedFunctions = filterSupportedFunctions;
Expand Down Expand Up @@ -190,8 +182,7 @@ public static TableDelegationInfo ToDelegationInfo(ServiceCapabilities serviceCa
SortRestriction = sortRestriction,
FilterRestriction = filterRestriction,
SelectionRestriction = selectionRestriction,
GroupRestriction = groupRestriction,
FilterFunctions = serviceCapabilities?.FilterFunctionsEnum,
GroupRestriction = groupRestriction,
FilterSupportedFunctions = serviceCapabilities?.FilterSupportedFunctionsEnum,
PagingCapabilities = pagingCapabilities,
SupportsRecordPermission = serviceCapabilities?.SupportsRecordPermission ?? false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CdpTable : CdpService

public override HttpClient HttpClient => _httpClient;

public override bool IsDelegable => (DelegationInfo?.SortRestriction != null) || (DelegationInfo?.FilterRestriction != null) || (DelegationInfo?.FilterFunctions != null);
public override bool IsDelegable => (DelegationInfo?.SortRestriction != null) || (DelegationInfo?.FilterRestriction != null) || (DelegationInfo?.FilterSupportedFunctions != null);

internal TableDelegationInfo DelegationInfo => ((DataSourceInfo)TabularTableDescriptor.FormulaType._type.AssociatedDataSources.First()).DelegationInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ internal interface IExternalRule

// Returns true when Binding is non-null, otherwise false.
bool HasValidBinding { get; }

// Returns true when rule is constant.
bool IsInvariantExpression { get; }
}
}
4 changes: 1 addition & 3 deletions src/libraries/Microsoft.PowerFx.Core/Binding/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3619,9 +3619,7 @@ public override void PostVisit(DottedNameNode node)
// we need to mark the node as constant, and save the control info so we may look up the
// rule later.
if (controlInfo?.GetRule(property.InvariantName) is IExternalRule rule &&
rule.HasValidBinding &&
!rule.HasErrorsOrWarnings &&
rule.Binding.IsConstant(rule.Binding.Top))
rule.IsInvariantExpression)
{
value = controlInfo;
isConstant = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public abstract class TableDelegationInfo
public GroupRestrictions GroupRestriction { get; init; }

// Filter functions supported by all columns of the table
public IEnumerable<DelegationOperator> FilterFunctions { get; init; }

// Filter functions supported by the table
public IEnumerable<DelegationOperator> FilterSupportedFunctions { get; init; }

// Defines paging capabilities
Expand Down Expand Up @@ -59,7 +56,7 @@ public abstract class TableDelegationInfo
// Key = field logical name, Value = foreign table logical name
internal Dictionary<string, string> ColumnsWithRelationships { get; init; }

public virtual bool IsDelegable => IsSortable || (FilterRestriction != null) || (FilterFunctions != null);
public virtual bool IsDelegable => IsSortable || (FilterRestriction != null) || (FilterSupportedFunctions != null);

public TableDelegationInfo()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class CdpFilterOpMetadata : FilterOpMetadata
private readonly TableDelegationInfo _delegationInfo;

public CdpFilterOpMetadata(AggregateType schema, TableDelegationInfo delegationInfo)
: base(schema._type, null, null, GetFilterFunctionsSupportedByAllColumns(delegationInfo), GetFilterFunctionSupportedByTable(delegationInfo))
: base(schema._type, null, null, GetFilterFunctionsSupportedByAllColumns(delegationInfo), null)
{
_delegationInfo = delegationInfo;
}
Expand All @@ -21,9 +21,9 @@ private static DelegationCapability GetFilterFunctionsSupportedByAllColumns(Tabl
{
DelegationCapability filterFunctionSupportedByAllColumns = DelegationCapability.None;

if (delegationInfo?.FilterFunctions != null)
if (delegationInfo?.FilterSupportedFunctions != null)
{
foreach (DelegationOperator globalFilterFunctionEnum in delegationInfo.FilterFunctions)
foreach (DelegationOperator globalFilterFunctionEnum in delegationInfo.FilterSupportedFunctions)
{
string globalFilterFunction = globalFilterFunctionEnum.ToString().ToLowerInvariant();

Expand All @@ -35,29 +35,7 @@ private static DelegationCapability GetFilterFunctionsSupportedByAllColumns(Tabl
}

return filterFunctionSupportedByAllColumns;
}

private static DelegationCapability? GetFilterFunctionSupportedByTable(TableDelegationInfo delegationInfo)
{
DelegationCapability? filterFunctionsSupportedByTable = null;

if (delegationInfo?.FilterSupportedFunctions != null)
{
filterFunctionsSupportedByTable = DelegationCapability.None;

foreach (DelegationOperator globalSupportedFilterFunctionEnum in delegationInfo.FilterSupportedFunctions)
{
string globalSupportedFilterFunction = globalSupportedFilterFunctionEnum.ToString().ToLowerInvariant();

if (DelegationCapability.OperatorToDelegationCapabilityMap.TryGetValue(globalSupportedFilterFunction, out DelegationCapability globalSupportedFilterFunctionCapability))
{
filterFunctionsSupportedByTable |= globalSupportedFilterFunctionCapability | DelegationCapability.Filter;
}
}
}

return filterFunctionsSupportedByTable;
}
}

public override bool TryGetColumnCapabilities(DPath columnPath, out DelegationCapability capabilities)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ internal static class TexlStrings
public static ErrorResourceKey ErrReachedMaxJsonLength = new ErrorResourceKey("ErrReachedMaxJsonLength");

public static ErrorResourceKey ErrUserDefinedTypesDisabled = new ErrorResourceKey("ErrUserDefinedTypesDisabled");

public static ErrorResourceKey ErrUserDefinedTypeIncorrectSyntax = new ErrorResourceKey("ErrUserDefinedTypeIncorrectSyntax");
public static ErrorResourceKey ErrJoinCantUnion = new ErrorResourceKey("ErrJoinCantUnion");
}
}
8 changes: 8 additions & 0 deletions src/libraries/Microsoft.PowerFx.Core/Parser/TexlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ private ParseUserDefinitionResult ParseUDFsAndNamedFormulas(string script, Parse
}
else if (_curs.TidCur == TokKind.Equ)
{
var equalToken = _curs.TokCur;

var declaration = script.Substring(declarationStart, _curs.TokCur.Span.Min - declarationStart);
_curs.TokMove();
definitionBeforeTrivia.Add(ParseTrivia());
Expand All @@ -385,6 +387,12 @@ private ParseUserDefinitionResult ParseUDFsAndNamedFormulas(string script, Parse
definitionBeforeTrivia.Add(ParseTrivia());
var result = ParseExpr(Precedence.None);

if (result is TypeLiteralNode _)
{
CreateError(equalToken, TexlStrings.ErrUserDefinedTypeIncorrectSyntax);
continue;
}

namedFormulas.Add(new NamedFormula(thisIdentifier.As<IdentToken>(), new Formula(result.GetCompleteSpan().GetFragment(script), result), _startingIndex, attribute));
userDefinitionSourceInfos.Add(new UserDefinitionSourceInfo(index++, UserDefinitionType.NamedFormula, thisIdentifier.As<IdentToken>(), declaration, new SourceList(definitionBeforeTrivia), GetExtraTriviaSourceList()));
definitionBeforeTrivia = new List<ITexlSource>();
Expand Down
78 changes: 76 additions & 2 deletions src/strings/PowerFxResources.bg-BG.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3620,6 +3620,18 @@
<data name="ErrorResource_ErrBehaviorPropertyExpected_Link_1_URL" xml:space="preserve">
<value>https://go.microsoft.com/fwlink/?linkid=2132570</value>

</data>
<data name="ErrorResource_ErrBehaviorFunctionInDataUDF_ShortMessage" xml:space="preserve">
<value>Функция за поведение в дефинирана от потребителя функция (UDF), несвързана с поведение. Моля, поставете тялото на дефинираната от потребителя функция във фигурни скоби ({...}), за да декларирате функция за поведение.</value>

</data>
<data name="ErrorResource_ErrBehaviorFunctionInDataUDF_LongMessage" xml:space="preserve">
<value>Функциите за поведение променят текущото състояние на сесията. Често срещани такива функции са Clear, Collect, Patch и Refresh.</value>

</data>
<data name="ErrorResource_ErrBehaviorFunctionInDataUDF_HowToFix_1" xml:space="preserve">
<value>Редактирайте израза на дефинираната от потребителя функция, така че да е във фигурни скоби ({...}).</value>

</data>
<data name="ErrorResource_ErrTestPropertyExpected_ShortMessage" xml:space="preserve">
<value>Тестова функция в нетестово свойство. Не можете да използвате това свойство, за да извиквате функции само за тестване.</value>
Expand Down Expand Up @@ -4014,6 +4026,60 @@
<data name="ErrorResource_SuggestRemoteExecutionHint_InOpInvalidColumn_Link_2_URL" xml:space="preserve">
<value>https://go.microsoft.com/fwlink/?linkid=2132702</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_ShortMessage" xml:space="preserve">
<value>Предупреждение за делегиране. Наименуваната формула {0} не може да бъде делегирана, така че използването ѝ в тази формула може да не работи правилно при големи набори от данни. </value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_LongMessage" xml:space="preserve">
<value>Възможно е източникът на данни да не е в състояние да обработи формулата и да върне непълен набор от данни. Вашето приложение може да не върне правилни резултати или поведението му може да е неправилно, ако наборът от данни е непълен.</value>
</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_HowToFix_1" xml:space="preserve">
<value>Опитайте да опростите дефиницията на наименуваната формула.</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_Link_1" xml:space="preserve">
<value>Статия: Разбиране на делегирането в приложение за платно</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_Link_1_URL" xml:space="preserve">
<value>https://go.microsoft.com/fwlink/?linkid=2132701</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_Link_2" xml:space="preserve">
<value>Блог: Ограничения за редовете с данни за делегиране</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_NF_Link_2_URL" xml:space="preserve">
<value>https://go.microsoft.com/fwlink/?linkid=2132702</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_ShortMessage" xml:space="preserve">
<value>Предупреждение за делегиране. Дефинираната от потребителя функция {0} не може да бъде делегирана, така че използването ѝ в тази формула може да не работи правилно при големи набори от данни. </value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_LongMessage" xml:space="preserve">
<value>Възможно е източникът на данни да не е в състояние да обработи формулата и да върне непълен набор от данни. Вашето приложение може да не върне правилни резултати или поведението му може да е неправилно, ако наборът от данни е непълен.</value>
</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_HowToFix_1" xml:space="preserve">
<value>Опитайте да опростите дефиницията на дефинираната от потребителя функция.</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_Link_1" xml:space="preserve">
<value>Статия: Разбиране на делегирането в приложение за платно</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_Link_1_URL" xml:space="preserve">
<value>https://go.microsoft.com/fwlink/?linkid=2132701</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_Link_2" xml:space="preserve">
<value>Блог: Ограничения за редовете с данни за делегиране</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_UDF_Link_2_URL" xml:space="preserve">
<value>https://go.microsoft.com/fwlink/?linkid=2132702</value>

</data>
<data name="ErrorResource_SuggestRemoteExecutionHint_OpNotSupportedByService_ShortMessage" xml:space="preserve">
<value>Предупреждение за делегиране. Осветената част на тази формула може да не работи правилно при големи набори от данни. Операцията „{0}“ не се поддържа от този конектор.</value>
Expand Down Expand Up @@ -4116,7 +4182,7 @@

</data>
<data name="ErrNamedType_MissingTypeLiteral" xml:space="preserve">
<value>Named type must be a type literal.</value>
<value>Именуваният тип трябва да е литерал за тип.</value>

</data>
<data name="ErrUDF_MissingFunctionBody" xml:space="preserve">
Expand Down Expand Up @@ -4757,7 +4823,7 @@

</data>
<data name="ErrUnsupportedTypeInTypeArgument" xml:space="preserve">
<value>Неподдържан нетипизиран тип/тип преобразуване JSON „{0}“ в аргумента.</value>
<value>Неподдържан тип „{0}“ в аргумента за тип.</value>

</data>
<data name="ErrReachedMaxJsonDepth" xml:space="preserve">
Expand All @@ -4768,4 +4834,12 @@
<value>Във функцията в JSON бе достигната максималната дължина.</value>

</data>
<data name="ErrUserDefinedTypesDisabled" xml:space="preserve">
<value>Експерименталната функция за дефинирани от потребителя типове не е активирана.</value>

</data>
<data name="ErrUserDefinedTypeIncorrectSyntax" xml:space="preserve">
<value>Неправилен синтаксис: „=“ не може да се използва за деклариране на дефинирани от потребителя типове. Вместо това използвайте „:=“.</value>

</data>
</root>
Loading

0 comments on commit c62088c

Please sign in to comment.