Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Update nuget dependencies #59

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Directory.Packages.Props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<!-- use 'PackageVersion' rather than 'PackageReference' -->
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
<PackageVersion Include="Azure.Identity" Version="1.12.1" />
<PackageVersion Include="Azure.Monitor.Query" Version="1.5.0" />
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Fastenshtein" Version="1.0.10" />
Expand All @@ -14,29 +14,29 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.5" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2651.64" />
<PackageVersion Include="NLog" Version="5.3.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.5.2" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2792.45" />
<PackageVersion Include="NLog" Version="5.3.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="MSTest.TestFramework" Version="3.6.0" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageVersion Include="NotNullStrings" Version="1.0.1" />
<PackageVersion Include="Parquet.Net" Version="4.24.0" />
<PackageVersion Include="Parquet.Net" Version="4.25.0" />
<PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Management.Automation" Version="7.4.1" />
<PackageVersion Include="T-Digest.NET" Version="1.0.3" />
<PackageVersion Include="VegaGenerator" Version="1.0.2" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.Azure.Kusto.Language" Version="11.6.1" />
<PackageVersion Include="Microsoft.Azure.Kusto.Language" Version="11.7.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="CsvHelper" Version="33.0.1" />
<PackageVersion Include="geohash-dotnet" Version="2.1.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="geohash-dotnet" Version="2.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.8.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static CustomFunctions()
StringSimilarity.Register(functions);
DateTimeToIso.Register(functions);
TrimWsFunction.Register(functions);
PadLeftFunction.Register(functions);
PadRightFunction.Register(functions);
ToDateTimeFmtFunction.Register(functions);
ParseHexFunction.Register(functions);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace KustoLoco.Core.Evaluation.BuiltIns.Impl;

[KustoImplementation(Keyword = "padleft")]
internal partial class PadLeftFunction
{
private static string Impl(string s,long n) => s.PadLeft((int)n,' ');
private static string WithCharImpl(string s,long n,string pad) => s.PadLeft((int)n,pad.Length >0 ? pad[0]:' ');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace KustoLoco.Core.Evaluation.BuiltIns.Impl;

[KustoImplementation(Keyword = "padright")]
internal partial class PadRightFunction
{
private static string Impl(string s,long n) => s.PadRight((int)n,' ');
private static string WithCharImpl(string s,long n,string pad) => s.PadRight((int)n,pad.Length >0 ? pad[0]:' ');
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ namespace KustoLoco.Core.Evaluation.BuiltIns.Impl;
[KustoImplementation(Keyword = "Functions.Substring")]
internal partial class SubstringFunction
{
private static string Impl(string input, long start, long length)
internal static string Impl(string input, long start, long length)
{
var effectiveStart = Math.Max(0, Math.Min(start, input.Length));
var maxAllowableLength = input.Length - effectiveStart;
var effectiveLength =
Math.Max(0, Math.Min(length, maxAllowableLength));
return input.Substring((int)effectiveStart, (int)effectiveLength);
}
}

private static string AImpl(string input, long start)
{
return SubstringFunction.Impl(input, start, int.MaxValue);
}
}
61 changes: 61 additions & 0 deletions test/BasicTests/SimpleFunctionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ public async Task SubString()
result.Should().Be("Cde");
}

[TestMethod]
public async Task SubStringSingleParameter()
{
var query = "print c=substring('ABCdef',2)";
var result = await LastLineOfResult(query);
result.Should().Be("Cdef");
}


[TestMethod]
public async Task Trimws()
{
Expand All @@ -140,6 +149,58 @@ public async Task Trimws()
result.Should().Be("abc");
}



[TestMethod]
public async Task PadLeft()
{
var query = "print c=padleft('abc',6)";
var result = await LastLineOfResult(query);
result.Should().Be(" abc");
}

[TestMethod]
public async Task PadLeftWithChar()
{
var query = "print c=padleft('abc',6,'A')";
var result = await LastLineOfResult(query);
result.Should().Be("AAAabc");
}


[TestMethod]
public async Task PadLeftWithBlankChar()
{
var query = "print c=padleft('abc',6,'')";
var result = await LastLineOfResult(query);
result.Should().Be(" abc");
}

[TestMethod]
public async Task PadRight()
{
var query = "print c=padright('abc',6)";
var result = await LastLineOfResult(query);
result.Should().Be("abc ");
}

[TestMethod]
public async Task PadRightWithChar()
{
var query = "print c=padright('abc',6,'A')";
var result = await LastLineOfResult(query);
result.Should().Be("abcAAA");
}


[TestMethod]
public async Task PadRightWithBlankChar()
{
var query = "print c=padright('abc',6,'')";
var result = await LastLineOfResult(query);
result.Should().Be("abc ");
}

[TestMethod]
public async Task DateTimeBin()
{
Expand Down