@@ -86,8 +86,8 @@ public void TestCreateDataFrame()
86
86
new StructField ( "Name" , new StringType ( ) ) ,
87
87
new StructField ( "Age" , new IntegerType ( ) )
88
88
} ) ;
89
- DataFrame df = _spark . CreateDataFrame ( data , schema ) ;
90
- ValidateDataFrame < object [ ] > ( data . ConvertAll ( a => a . Values ) , df , schema ) ;
89
+ DataFrame df = _spark . CreateDataFrame ( data , schema ) ;
90
+ ValidateDataFrame ( data . Select ( a => a . Values ) , df , schema ) ;
91
91
}
92
92
93
93
// Calling CreateDataFrame(IEnumerable<string> _) without schema
@@ -99,7 +99,7 @@ public void TestCreateDataFrame()
99
99
} ) ;
100
100
101
101
DataFrame df = _spark . CreateDataFrame ( data ) ;
102
- ValidateDataFrame < object [ ] > ( data . ConvertAll ( a => new object [ ] { a } ) , df , schema ) ;
102
+ ValidateDataFrame ( data . Select ( a => new object [ ] { a } ) , df , schema ) ;
103
103
}
104
104
105
105
// Calling CreateDataFrame(IEnumerable<int> _) without schema
@@ -111,7 +111,7 @@ public void TestCreateDataFrame()
111
111
} ) ;
112
112
113
113
DataFrame df = _spark . CreateDataFrame ( data ) ;
114
- ValidateDataFrame < object [ ] > ( data . ConvertAll ( a => new object [ ] { a } ) , df , schema ) ;
114
+ ValidateDataFrame ( data . Select ( a => new object [ ] { a } ) , df , schema ) ;
115
115
}
116
116
117
117
// Calling CreateDataFrame(IEnumerable<double> _) without schema
@@ -123,7 +123,7 @@ public void TestCreateDataFrame()
123
123
} ) ;
124
124
125
125
DataFrame df = _spark . CreateDataFrame ( data ) ;
126
- ValidateDataFrame < object [ ] > ( data . ConvertAll ( a => new object [ ] { a } ) , df , schema ) ;
126
+ ValidateDataFrame ( data . Select ( a => new object [ ] { a } ) , df , schema ) ;
127
127
}
128
128
129
129
// Calling CreateDataFrame(IEnumerable<bool> _) without schema
@@ -135,7 +135,19 @@ public void TestCreateDataFrame()
135
135
} ) ;
136
136
137
137
DataFrame df = _spark . CreateDataFrame ( data ) ;
138
- ValidateDataFrame < object [ ] > ( data . ConvertAll ( a => new object [ ] { a } ) , df , schema ) ;
138
+ ValidateDataFrame ( data . Select ( a => new object [ ] { a } ) , df , schema ) ;
139
+ }
140
+
141
+ // Calling CreateDataFrame(IEnumerable<long> _) without schema
142
+ {
143
+ var data = new List < long > ( new long [ ] { 2L , 3L } ) ;
144
+ var schema = new StructType ( new List < StructField > ( )
145
+ {
146
+ new StructField ( "_1" , new LongType ( ) )
147
+ } ) ;
148
+
149
+ DataFrame df = _spark . CreateDataFrame ( data ) ;
150
+ ValidateDataFrame ( data . Select ( a => new object [ ] { a } ) , df , schema ) ;
139
151
}
140
152
}
141
153
@@ -146,14 +158,18 @@ public void TestCreateDataFrame()
146
158
/// <param name="data">Given data for the dataframe</param>
147
159
/// <param name="df">Dataframe Object to validate</param>
148
160
/// <param name="schema">Expected schema of the dataframe</param>
149
- internal void ValidateDataFrame < T > ( List < object [ ] > data , DataFrame df , StructType schema )
161
+ private void ValidateDataFrame ( IEnumerable < object [ ] > data , DataFrame df , StructType schema )
150
162
{
151
163
Assert . Equal ( schema , df . Schema ( ) ) ;
152
164
Row [ ] rows = df . Collect ( ) . ToArray ( ) ;
153
- Assert . Equal ( data . Count , rows . Length ) ;
154
- for ( int i = 0 ; i < rows . Length ; ++ i )
165
+ Assert . Equal ( data . Count ( ) , rows . Length ) ;
166
+ int i = 0 ;
167
+ foreach ( object [ ] expectedValues in data )
155
168
{
156
- Assert . Equal ( data [ i ] , rows [ i ] . Values ) ;
169
+ object [ ] actualValues = rows [ i ] . Values ;
170
+ Assert . Equal ( expectedValues . Length , actualValues . Length ) ;
171
+ Assert . True ( actualValues . SequenceEqual ( expectedValues ) ) ;
172
+ ++ i ;
157
173
}
158
174
}
159
175
}
0 commit comments