-
Notifications
You must be signed in to change notification settings - Fork 5
[SPARK-51815] Add Row
struct
#63
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
import Foundation | ||
|
||
public struct Row: Sendable, Equatable { | ||
let values: [Sendable?] | ||
|
||
public init(_ values: Sendable?...) { | ||
self.values = values | ||
} | ||
|
||
public init(valueArray: [Sendable?]) { | ||
self.values = valueArray | ||
} | ||
|
||
public static var empty: Row { | ||
return Row() | ||
} | ||
|
||
public var size: Int { return length } | ||
|
||
public var length: Int { return values.count } | ||
|
||
subscript(index: Int) -> Sendable { | ||
get throws { | ||
return try get(index) | ||
} | ||
} | ||
|
||
public func get(_ i: Int) throws -> Sendable { | ||
if i < 0 || i >= self.length { | ||
throw SparkConnectError.InvalidArgumentException | ||
} | ||
return values[i] | ||
} | ||
|
||
public static func == (lhs: Row, rhs: Row) -> Bool { | ||
if lhs.values.count != rhs.values.count { | ||
return false | ||
} | ||
return lhs.values.elementsEqual(rhs.values) { (x, y) in | ||
if x == nil && y == nil { | ||
return true | ||
} else if let a = x as? Bool, let b = y as? Bool { | ||
return a == b | ||
} else if let a = x as? Int, let b = y as? Int { | ||
return a == b | ||
} else if let a = x as? Int8, let b = y as? Int8 { | ||
return a == b | ||
} else if let a = x as? Int16, let b = y as? Int16 { | ||
return a == b | ||
} else if let a = x as? Int32, let b = y as? Int32 { | ||
return a == b | ||
} else if let a = x as? Int64, let b = y as? Int64 { | ||
return a == b | ||
} else if let a = x as? Float, let b = y as? Float { | ||
return a == b | ||
} else if let a = x as? Double, let b = y as? Double { | ||
return a == b | ||
} else if let a = x as? String, let b = y as? String { | ||
return a == b | ||
} else { | ||
return false | ||
} | ||
} | ||
} | ||
|
||
public func toString() -> String { | ||
return "[\(self.values.map { "\($0 ?? "null")" }.joined(separator: ","))]" | ||
} | ||
} | ||
|
||
extension Row { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[[61 62 63]] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[2025-03-15 00:00:00 +0000] |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,5 @@ | ||||||||||||||||||||||||||||||||
[Catalog Name,spark_catalog] | ||||||||||||||||||||||||||||||||
[Namespace Name,default] | ||||||||||||||||||||||||||||||||
[Comment,default database] | ||||||||||||||||||||||||||||||||
[Location,*] | ||||||||||||||||||||||||||||||||
[Owner,*] | ||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, why the the second elements of the two items ["Location","file:/opt/spark/work-dir/spark-warehouse"],["Owner","185"] are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During the spark-connect-swift/Tests/SparkConnectTests/SQLTests.swift Lines 36 to 50 in 21724f5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Thank you. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Function: abs] | ||
[Class: org.apache.spark.sql.catalyst.expressions.Abs] | ||
[Usage: abs(expr) - Returns the absolute value of the numeric or interval value.] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[id,int,null] | ||
[name,string,null] | ||
[salary,double,null] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[col,int,null] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[== Parsed Logical Plan == | ||
'Aggregate ['k], ['k, unresolvedalias('sum('v))] | ||
+- SubqueryAlias t | ||
+- LocalRelation [k#, v#] | ||
|
||
== Analyzed Logical Plan == | ||
k: int, sum(v): bigint | ||
Aggregate [k#], [k#, sum(v#) AS sum(v)#] | ||
+- SubqueryAlias t | ||
+- LocalRelation [k#, v#] | ||
|
||
== Optimized Logical Plan == | ||
Aggregate [k#], [k#, sum(v#) AS sum(v)#] | ||
+- LocalRelation [k#, v#] | ||
|
||
== Physical Plan == | ||
AdaptiveSparkPlan isFinalPlan=false | ||
+- HashAggregate(keys=[k#], functions=[sum(v#)], output=[k#, sum(v)#]) | ||
+- Exchange hashpartitioning(k#, 200), ENSURE_REQUIREMENTS, [plan_id=] | ||
+- HashAggregate(keys=[k#], functions=[partial_sum(v#)], output=[k#, sum#]) | ||
+- LocalTableScan [k#, v#] | ||
] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[1.0,-2.0,3.0,-4.0,inf,nan,inf,nan] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[127,-128,32767,-32768,2147483647,-2147483648,9223372036854775807,-9223372036854775808] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[0,0] | ||
[1,2] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[1] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[default] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[,testcache,true] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[abc,def] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{1},{2,{3}}] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file was deleted.
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.
This is still stored the value as string? So we still cannot insert column values into Row in their types?
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.
Yes~ This is a part-one implementation to introduce
Row
struct like the note in the PR description.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.
Got it. Thank you.