-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-40774][CONNECT] Add Sample to proto and Connect DSL #38227
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 |
|---|---|---|
|
|
@@ -46,15 +46,16 @@ package object dsl { | |
| .build() | ||
|
|
||
| def struct( | ||
| attrs: proto.Expression.QualifiedAttribute*): proto.Expression.QualifiedAttribute = { | ||
| attrs: proto.Expression.QualifiedAttribute*): proto.Expression.QualifiedAttribute = { | ||
| val structExpr = proto.DataType.Struct.newBuilder() | ||
| for (attr <- attrs) { | ||
| val structField = proto.DataType.StructField.newBuilder() | ||
| structField.setName(attr.getName) | ||
| structField.setType(attr.getType) | ||
| structExpr.addFields(structField) | ||
| } | ||
| proto.Expression.QualifiedAttribute.newBuilder() | ||
| proto.Expression.QualifiedAttribute | ||
| .newBuilder() | ||
| .setName(s) | ||
| .setType(proto.DataType.newBuilder().setStruct(structExpr)) | ||
| .build() | ||
|
|
@@ -65,8 +66,9 @@ package object dsl { | |
| proto.DataType.newBuilder().setI32(proto.DataType.I32.newBuilder()).build()) | ||
|
|
||
| private def protoQualifiedAttrWithType( | ||
| dataType: proto.DataType): proto.Expression.QualifiedAttribute = | ||
| proto.Expression.QualifiedAttribute.newBuilder() | ||
| dataType: proto.DataType): proto.Expression.QualifiedAttribute = | ||
| proto.Expression.QualifiedAttribute | ||
| .newBuilder() | ||
| .setName(s) | ||
| .setType(dataType) | ||
| .build() | ||
|
|
@@ -180,6 +182,24 @@ package object dsl { | |
| .build() | ||
| } | ||
|
|
||
| def sample( | ||
|
Contributor
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. Are all of these parameters required? Or are some optional?
Contributor
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. are all required
Contributor
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. are all required for the
Contributor
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 think we can go with the query plan for now and if we want to introduce optional behavior it's going to be easy to do because the proto supports optionality by default. |
||
| lowerBound: Double, | ||
| upperBound: Double, | ||
| withReplacement: Boolean, | ||
| seed: Long): proto.Relation = { | ||
| proto.Relation | ||
| .newBuilder() | ||
| .setSample( | ||
| proto.Sample | ||
| .newBuilder() | ||
| .setInput(logicalPlan) | ||
| .setUpperBound(upperBound) | ||
| .setLowerBound(lowerBound) | ||
| .setWithReplacement(withReplacement) | ||
| .setSeed(seed)) | ||
| .build() | ||
| } | ||
|
|
||
| def groupBy(groupingExprs: proto.Expression*)( | ||
| aggregateExprs: proto.Expression*): proto.Relation = { | ||
| val agg = proto.Aggregate.newBuilder() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.