-
Notifications
You must be signed in to change notification settings - Fork 329
Feature/decimal support #982
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
Open
GoEddie
wants to merge
19
commits into
dotnet:main
Choose a base branch
from
GoEddie:feature/DecimalSupport
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e42a0c4
Check whether file is found before trying to dereference it
ca84f6a
switching to null conditional check
5dc2143
Update src/csharp/Microsoft.Spark/Utils/UdfSerDe.cs
GoEddie aefc393
Merge branch 'master' of github.com:GoEddie/spark
9d31c3a
Merge branch 'master' of github.com:dotnet/spark
c5b660d
Merge branch 'master' of github.com:dotnet/spark
ec9ca58
Merge branch 'master' of github.com:dotnet/spark
4f29c18
Merge branch 'master' of github.com:dotnet/spark
3c1b505
Merge branch 'main' of github.com:dotnet/spark
338210a
Decimal Support
66e357b
isnt used
ceab50f
unnecessary import
7ff1c8e
formatting
546ba36
other versions
a72e152
extra line
4c88ece
test
592a57d
comment
c33f697
Merge branch 'main' into feature/DecimalSupport
GoEddie f9a0aa0
Merge branch 'main' into feature/DecimalSupport
GoEddie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test
- Loading branch information
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/DataTypesTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.Spark.Sql; | ||
using Microsoft.Spark.Sql.Types; | ||
using Xunit; | ||
|
||
namespace Microsoft.Spark.E2ETest.IpcTests | ||
{ | ||
|
||
[Collection("Spark E2E Tests")] | ||
public class DataTypesTests | ||
{ | ||
private readonly SparkSession _spark; | ||
|
||
public DataTypesTests(SparkFixture fixture) | ||
{ | ||
_spark = fixture.Spark; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[Fact] | ||
public void TestDecimalType() | ||
{ | ||
var df = _spark.CreateDataFrame( | ||
new List<GenericRow> | ||
{ | ||
new GenericRow( | ||
new object[] | ||
{ | ||
decimal.MinValue, decimal.MaxValue, decimal.Zero, decimal.MinusOne, | ||
new object[] | ||
{ | ||
decimal.MinValue, decimal.MaxValue, decimal.Zero, decimal.MinusOne | ||
} | ||
}), | ||
}, | ||
new StructType( | ||
new List<StructField>() | ||
{ | ||
new StructField("min", new DecimalType(38, 0)), | ||
new StructField("max", new DecimalType(38, 0)), | ||
new StructField("zero", new DecimalType(38, 0)), | ||
new StructField("minusOne", new DecimalType(38, 0)), | ||
new StructField("array", new ArrayType(new DecimalType(38,0))) | ||
})); | ||
|
||
Row row = df.Collect().First(); | ||
Assert.Equal(decimal.MinValue, row[0]); | ||
Assert.Equal(decimal.MaxValue, row[1]); | ||
Assert.Equal(decimal.Zero, row[2]); | ||
Assert.Equal(decimal.MinusOne, row[3]); | ||
Assert.Equal(new object[]{decimal.MinValue, decimal.MaxValue, decimal.Zero, decimal.MinusOne}, | ||
row[4]); | ||
} | ||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't gotten to dive deep into whether this is an issue yet, but want to bring it to attention just in case:
There was a time when we were comparing SQL Server output to Spark SQL output trying to migrate a pipeline to Synapse, and when attempting to diff two tables, found an issue with a
double
.SQL Server uses, presumably, C#'s (and JavaScript, which the Python Notebook table preview in Synapse uses)'s conception of floats:



-0.0 == 0.0
, but the JVM/Spark in some cases compares by bit and differentiates because of the signed bit:-0.0 != 0.0
.It's resolved in later versions of Spark's DataFrames, and may not apply in the case of
[decimal]String
, so it may not be problematic.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay!