-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-49828][SQL] Expose ColumnNode to/from Expression utils as developer APIs #48306
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 |
|---|---|---|
|
|
@@ -14,11 +14,10 @@ | |
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.sql.internal | ||
|
|
||
| import UserDefinedFunctionUtils.toScalaUDF | ||
| package org.apache.spark.sql.util | ||
|
|
||
| import org.apache.spark.SparkException | ||
| import org.apache.spark.annotation.DeveloperApi | ||
| import org.apache.spark.sql.{Column, Dataset, SparkSession} | ||
| import org.apache.spark.sql.catalyst.{analysis, expressions, CatalystTypeConverters} | ||
| import org.apache.spark.sql.catalyst.analysis.{MultiAlias, UnresolvedAlias} | ||
|
|
@@ -32,6 +31,8 @@ import org.apache.spark.sql.execution.SparkSqlParser | |
| import org.apache.spark.sql.execution.aggregate.{ScalaAggregator, ScalaUDAF, TypedAggregateExpression} | ||
| import org.apache.spark.sql.execution.analysis.DetectAmbiguousSelfJoin | ||
| import org.apache.spark.sql.expressions.{Aggregator, SparkUserDefinedFunction, UserDefinedAggregateFunction, UserDefinedAggregator} | ||
| import org.apache.spark.sql.internal._ | ||
| import org.apache.spark.sql.internal.UserDefinedFunctionUtils.toScalaUDF | ||
| import org.apache.spark.sql.types.{DataType, NullType} | ||
|
|
||
| /** | ||
|
|
@@ -248,7 +249,8 @@ private[sql] trait ColumnNodeToExpressionConverter extends (ColumnNode => Expres | |
| } | ||
| } | ||
|
|
||
| private[sql] object ColumnNodeToExpressionConverter extends ColumnNodeToExpressionConverter { | ||
| @DeveloperApi | ||
| object ColumnNodeToExpressionConverter extends ColumnNodeToExpressionConverter { | ||
| override protected def parser: ParserInterface = { | ||
| SparkSession.getActiveSession.map(_.sessionState.sqlParser).getOrElse { | ||
| new SparkSqlParser() | ||
|
|
@@ -261,7 +263,8 @@ private[sql] object ColumnNodeToExpressionConverter extends ColumnNodeToExpressi | |
| /** | ||
| * [[ColumnNode]] wrapper for an [[Expression]]. | ||
| */ | ||
| private[sql] case class ExpressionColumnNode private( | ||
| @DeveloperApi | ||
| case class ExpressionColumnNode private( | ||
|
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. You could use
Contributor
Author
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. So it doesn't do both the directions of the conversion and, as you point out, it's also an implicit conversion which (in my opinion) is some pretty unnecessary magic for this.
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. In this case implicits provide a way for a developer to make a minimal amount of changes, that is why they are there. I am generally not a big fan, but in this case they do make migration a lot easier. You could call |
||
| expression: Expression, | ||
| override val origin: Origin = CurrentOrigin.get) extends ColumnNode { | ||
| override def normalize(): ExpressionColumnNode = { | ||
|
|
@@ -282,7 +285,7 @@ private[sql] object ExpressionColumnNode { | |
| } | ||
| } | ||
|
|
||
| private[internal] case class ColumnNodeExpression private(node: ColumnNode) extends Unevaluable { | ||
| private[sql] case class ColumnNodeExpression private(node: ColumnNode) extends Unevaluable { | ||
| override def nullable: Boolean = true | ||
| override def dataType: DataType = NullType | ||
| override def children: Seq[Expression] = Nil | ||
|
|
||
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.
Quick question, we have an implicit class in
SparkSessioncalledRichColumn. That will 'restore' theexprfunctionality. Is that something that would work for you? Alternatively, if the use ofSparkSessionis cumbersome, we could also add another implicit class toorg.apache.spark.sql.classic.ClassicConversions.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.
So for Java users?
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.
Sure, I see your point. I would love to meet the Java developer that works with Spark internals :)...
They can still use these objects.