Issue https://github.com/microsoft/Power-Fx/issues/2671.
Still need to verify other functions.
This commit is contained in:
Anderson Silva 2024-10-03 11:18:06 -05:00 коммит произвёл GitHub
Родитель 1507ae41b5
Коммит 8cb65843a8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 52 добавлений и 2 удалений

Просмотреть файл

@ -127,7 +127,8 @@ namespace Microsoft.PowerFx.Core.Texl
public static readonly TexlFunction IsBlankOptionSetValue = _library.Add(new IsBlankOptionSetValueFunction());
public static readonly TexlFunction IsBlankOrError = _library.Add(new IsBlankOrErrorFunction());
public static readonly TexlFunction IsBlankOrErrorOptionSetValue = _library.Add(new IsBlankOrErrorOptionSetValueFunction());
public static readonly TexlFunction IsEmpty = _library.Add(new IsEmptyFunction());
public static readonly TexlFunction IsEmpty = _library.Add(new IsEmptyFunction());
public static readonly TexlFunction IsEmpty_UO = _library.Add(new IsEmptyFunction_UO());
public static readonly TexlFunction IsError = _library.Add(new IsErrorFunction());
public static readonly TexlFunction IsNumeric = _library.Add(new IsNumericFunction());
public static readonly TexlFunction ISOWeekNum = _library.Add(new ISOWeekNumFunction());
@ -253,7 +254,7 @@ namespace Microsoft.PowerFx.Core.Texl
public static readonly TexlFunction Decimal = _featureGateFunctions.Add(new DecimalFunction());
public static readonly TexlFunction Decimal_UO = _featureGateFunctions.Add(new DecimalFunction_UO());
public static readonly TexlFunction Float = _featureGateFunctions.Add(new FloatFunction());
public static readonly TexlFunction Float_UO = _featureGateFunctions.Add(new FloatFunction_UO());
public static readonly TexlFunction Float_UO = _featureGateFunctions.Add(new FloatFunction_UO());
public static readonly TexlFunction IsUTCToday = _featureGateFunctions.Add(new IsUTCTodayFunction());
public static readonly TexlFunction UTCNow = _featureGateFunctions.Add(new UTCNowFunction());
public static readonly TexlFunction UTCToday = _featureGateFunctions.Add(new UTCTodayFunction());

Просмотреть файл

@ -68,4 +68,19 @@ namespace Microsoft.PowerFx.Core.Texl.Builtins
return fValid;
}
}
internal sealed class IsEmptyFunction_UO : BuiltinFunction
{
public override bool IsSelfContained => true;
public IsEmptyFunction_UO()
: base("IsEmpty", TexlStrings.AboutIsEmpty, FunctionCategories.Table | FunctionCategories.Information, DType.Boolean, 0, 1, 1, DType.UntypedObject)
{
}
public override IEnumerable<TexlStrings.StringGetter[]> GetSignatures()
{
yield return new[] { TexlStrings.IsEmptyArg1 };
}
}
}

Просмотреть файл

@ -982,6 +982,17 @@ namespace Microsoft.PowerFx.Functions
returnBehavior: ReturnBehavior.AlwaysEvaluateAndReturnResult,
targetFunction: IsEmpty)
},
{
BuiltinFunctionsCore.IsEmpty_UO,
StandardErrorHandling<UntypedObjectValue>(
BuiltinFunctionsCore.IsEmpty_UO.Name,
expandArguments: NoArgExpansion,
replaceBlankValues: DoNotReplaceBlank,
checkRuntimeTypes: ExactValueTypeOrBlank<UntypedObjectValue>,
checkRuntimeValues: UntypedObjectArrayChecker,
returnBehavior: ReturnBehavior.ReturnBlankIfAnyArgIsBlank,
targetFunction: IsEmpty_UO)
},
{
BuiltinFunctionsCore.IsError,
NoErrorHandling(IsError)

Просмотреть файл

@ -67,6 +67,19 @@ namespace Microsoft.PowerFx.Functions
var result = element[0];
return new UntypedObjectValue(irContext, result);
}
public static FormulaValue IsEmpty_UO(IRContext irContext, UntypedObjectValue[] args)
{
var element = args[0].Impl;
var len = element.GetArrayLength();
if (len == 0)
{
return FormulaValue.New(true);
}
return FormulaValue.New(false);
}
public static FormulaValue Last_UO(IRContext irContext, UntypedObjectValue[] args)

Просмотреть файл

@ -114,6 +114,16 @@ true
),a > 10))
true
// Untyped object
>> IsEmpty(ParseJSON("[{""a"":1}]"))
false
>> IsEmpty(ParseJSON("[]"))
true
>> IsEmpty(ParseJSON("1"))
Error({Kind:ErrorKind.InvalidArgument})
// INVALID ARGUMENTS
>> IsEmpty("")
Errors: Error 8-10: Invalid argument type (Text). Expecting a Table value instead.