Skip to content

Commit

Permalink
Merge pull request #18 from apache/rename_packages
Browse files Browse the repository at this point in the history
Rename packages
  • Loading branch information
jmalkin authored Jan 29, 2025
2 parents 6779cde + 050710f commit 255b048
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.spark.sql.registrar
package org.apache.spark.sql.datasketches.common

import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.catalyst.FunctionIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* limitations under the License.
*/

package org.apache.spark.sql
package org.apache.spark.sql.datasketches.common

import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.catalyst.expressions.aggregate.AggregateFunction
import org.apache.spark.sql.Column

// this interfact provides a few helper methods defines and maps all the variants of each function invocation, analagous
// to the functions object in core Spark's org.apache.spark.sql.functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
* limitations under the License.
*/

package org.apache.spark.sql.registrar
package org.apache.spark.sql.datasketches.kll

import org.apache.spark.sql.catalyst.analysis.FunctionRegistry.FunctionBuilder
import org.apache.spark.sql.catalyst.expressions.{ExpressionInfo}

import org.apache.spark.sql.aggregate.{KllDoublesSketchAggBuild, KllDoublesSketchAggMerge}
import org.apache.spark.sql.expressions.{KllDoublesSketchGetMin, KllDoublesSketchGetMax, KllDoublesSketchGetPmf, KllDoublesSketchGetCdf}
import org.apache.spark.sql.datasketches.common.DatasketchesFunctionRegistry
import org.apache.spark.sql.datasketches.kll.aggregate.{KllDoublesSketchAggBuild, KllDoublesSketchAggMerge}
import org.apache.spark.sql.datasketches.kll.expressions.{KllDoublesSketchGetMin, KllDoublesSketchGetMax, KllDoublesSketchGetPmf, KllDoublesSketchGetCdf}
import org.apache.spark.sql.datasketches.common.DatasketchesFunctionRegistry

object KllFunctionRegistry extends DatasketchesFunctionRegistry {
override val expressions: Map[String, (ExpressionInfo, FunctionBuilder)] = Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
* limitations under the License.
*/

package org.apache.spark.sql.aggregate
package org.apache.spark.sql.datasketches.kll.aggregate

import org.apache.datasketches.kll.{KllSketch, KllDoublesSketch}
import org.apache.spark.sql.datasketches.kll.types.KllDoublesSketchType

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, Expression, ExpressionDescription, Literal}
import org.apache.spark.sql.catalyst.expressions.aggregate.TypedImperativeAggregate
import org.apache.spark.sql.catalyst.trees.BinaryLike
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, LongType, NumericType, FloatType, DoubleType, KllDoublesSketchType}
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, LongType, NumericType, FloatType, DoubleType}
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* limitations under the License.
*/

package org.apache.spark.sql.aggregate
package org.apache.spark.sql.datasketches.kll.aggregate

import org.apache.datasketches.memory.Memory
import org.apache.datasketches.kll.{KllSketch, KllDoublesSketch}
import org.apache.spark.sql.datasketches.kll.types.KllDoublesSketchType

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, Expression, ExpressionDescription, Literal}
import org.apache.spark.sql.catalyst.expressions.aggregate.TypedImperativeAggregate
import org.apache.spark.sql.catalyst.trees.BinaryLike
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, KllDoublesSketchType}
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType}
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package org.apache.spark.sql.expressions
package org.apache.spark.sql.datasketches.kll.expressions

import org.apache.datasketches.memory.Memory
import org.apache.datasketches.kll.KllDoublesSketch
import org.apache.datasketches.quantilescommon.QuantileSearchCriteria
import org.apache.spark.sql.types.KllDoublesSketchType
import org.apache.spark.sql.datasketches.kll.types.KllDoublesSketchType

import org.apache.spark.sql.types.{AbstractDataType, ArrayType, BooleanType, DataType, DoubleType}
import org.apache.spark.sql.catalyst.expressions.{Expression, ExpressionDescription, ExpectsInputTypes, ImplicitCastInputTypes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
* limitations under the License.
*/

package org.apache.spark.sql
package org.apache.spark.sql.datasketches.kll

import org.apache.spark.sql.Column
import org.apache.spark.sql.catalyst.expressions.Literal
import org.apache.spark.sql.functions.lit
import org.apache.spark.sql.types.{ArrayType, BooleanType, DoubleType}

import org.apache.spark.sql.aggregate.{KllDoublesSketchAggMerge, KllDoublesSketchAggBuild}
import org.apache.spark.sql.expressions.{KllDoublesSketchGetMin, KllDoublesSketchGetMax, KllDoublesSketchGetPmfCdf}
import org.apache.spark.sql.datasketches.common.DatasketchesScalaFunctionBase
import org.apache.spark.sql.datasketches.kll.aggregate.{KllDoublesSketchAggMerge, KllDoublesSketchAggBuild}
import org.apache.spark.sql.datasketches.kll.expressions.{KllDoublesSketchGetMin, KllDoublesSketchGetMax, KllDoublesSketchGetPmfCdf}

object functions_datasketches_kll extends DatasketchesScalaFunctionBase {
object functions extends DatasketchesScalaFunctionBase {

// build sketch
def kll_sketch_double_agg_build(expr: Column, k: Column): Column = withAggregateFunction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* limitations under the License.
*/

package org.apache.spark.sql.types
package org.apache.spark.sql.datasketches.kll.types

import org.apache.spark.sql.functions.udf
import org.apache.datasketches.kll.KllDoublesSketch
import org.apache.datasketches.memory.Memory
import org.apache.spark.sql.types.{DataType, DataTypes, UDTRegistration, UserDefinedType}

class KllDoublesSketchType extends UserDefinedType[KllDoublesSketch] with Serializable {
override def sqlType: DataType = DataTypes.BinaryType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
* limitations under the License.
*/

package org.apache.spark.sql.registrar
package org.apache.spark.sql.datasketches.theta

import org.apache.spark.sql.catalyst.analysis.FunctionRegistry.FunctionBuilder
import org.apache.spark.sql.catalyst.expressions.{ExpressionInfo}

import org.apache.spark.sql.aggregate.{ThetaSketchAggBuild, ThetaSketchAggUnion}
import org.apache.spark.sql.expressions.ThetaSketchGetEstimate
import org.apache.spark.sql.datasketches.common.DatasketchesFunctionRegistry
import org.apache.spark.sql.datasketches.theta.aggregate.{ThetaSketchAggBuild, ThetaSketchAggUnion}
import org.apache.spark.sql.datasketches.theta.expressions.ThetaSketchGetEstimate
import org.apache.spark.sql.datasketches.common.DatasketchesFunctionRegistry

object ThetaFunctionRegistry extends DatasketchesFunctionRegistry {
override val expressions: Map[String, (ExpressionInfo, FunctionBuilder)] = Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
* limitations under the License.
*/

package org.apache.spark.sql.aggregate
package org.apache.spark.sql.datasketches.theta.aggregate

import org.apache.datasketches.theta.{UpdateSketch, SetOperation}
import org.apache.spark.sql.datasketches.theta.types.{ThetaSketchType, ThetaSketchWrapper}

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, Expression, ExpressionDescription, Literal}
import org.apache.spark.sql.catalyst.expressions.aggregate.TypedImperativeAggregate
import org.apache.spark.sql.catalyst.trees.BinaryLike
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, LongType, NumericType, FloatType, DoubleType, ThetaSketchWrapper, ThetaSketchType}
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, LongType, NumericType, FloatType, DoubleType}

/**
* The ThetaSketchBuild function creates a Theta sketch from a column of values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* limitations under the License.
*/

package org.apache.spark.sql.aggregate
package org.apache.spark.sql.datasketches.theta.aggregate

import org.apache.datasketches.memory.Memory
import org.apache.datasketches.theta.{Sketch, SetOperation}
import org.apache.spark.sql.datasketches.theta.types.{ThetaSketchType, ThetaSketchWrapper}

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, Expression, ExpressionDescription, Literal}
import org.apache.spark.sql.catalyst.expressions.aggregate.TypedImperativeAggregate
import org.apache.spark.sql.catalyst.trees.BinaryLike
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, ThetaSketchWrapper, ThetaSketchType}
import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType}

/**
* Theta Union operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* limitations under the License.
*/

package org.apache.spark.sql.expressions
package org.apache.spark.sql.datasketches.theta.expressions

import org.apache.datasketches.memory.Memory
import org.apache.datasketches.theta.Sketch
import org.apache.spark.sql.datasketches.theta.types.ThetaSketchType

import org.apache.spark.sql.catalyst.expressions.{Expression, ExpectsInputTypes, UnaryExpression}
import org.apache.spark.sql.catalyst.expressions.NullIntolerant
import org.apache.spark.sql.catalyst.expressions.ExpressionDescription
import org.apache.spark.sql.catalyst.expressions.codegen.{CodeBlock, CodegenContext, ExprCode}
import org.apache.spark.sql.types.{AbstractDataType, DataType, DoubleType, ThetaSketchType}
import org.apache.spark.sql.types.{AbstractDataType, DataType, DoubleType}

@ExpressionDescription(
usage = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
* limitations under the License.
*/

package org.apache.spark.sql
package org.apache.spark.sql.datasketches.theta

import org.apache.spark.sql.Column
import org.apache.spark.sql.functions.lit

import org.apache.spark.sql.aggregate.{ThetaSketchAggBuild, ThetaSketchAggUnion}
import org.apache.spark.sql.expressions.ThetaSketchGetEstimate
import org.apache.spark.sql.datasketches.common.DatasketchesScalaFunctionBase
import org.apache.spark.sql.datasketches.theta.aggregate.{ThetaSketchAggBuild, ThetaSketchAggUnion}
import org.apache.spark.sql.datasketches.theta.expressions.ThetaSketchGetEstimate
import org.apache.spark.sql.datasketches.common.DatasketchesScalaFunctionBase

object functions_datasketches_theta extends DatasketchesScalaFunctionBase {
object functions extends DatasketchesScalaFunctionBase {
def theta_sketch_agg_build(column: Column, lgk: Int): Column = withAggregateFunction {
new ThetaSketchAggBuild(column.expr, lgk)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
* limitations under the License.
*/

package org.apache.spark.sql.types
package org.apache.spark.sql.datasketches.theta.types

import org.apache.spark.sql.types.{DataType, DataTypes, UserDefinedType}

class ThetaSketchType extends UserDefinedType[ThetaSketchWrapper] {
override def sqlType: DataType = DataTypes.BinaryType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* limitations under the License.
*/

package org.apache.spark.sql.types
package org.apache.spark.sql.datasketches.theta.types

import org.apache.datasketches.theta.{UpdateSketch, CompactSketch, Union}
import org.apache.datasketches.memory.Memory
import org.apache.spark.sql.types.SQLUserDefinedType

@SQLUserDefinedType(udt = classOf[ThetaSketchType])
class ThetaSketchWrapper(var updateSketch: Option[UpdateSketch] = None, var compactSketch: Option[CompactSketch] = None, var union: Option[Union] = None) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* limitations under the License.
*/

package org.apache.spark.sql
package org.apache.spark.sql.datasketches.common

import org.apache.log4j.{Level, Logger}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuite
import org.apache.spark.sql.SparkSession

/**
* This class provides a common base for tests. It can perhaps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* limitations under the License.
*/

package org.apache.spark.sql
package org.apache.spark.sql.datasketches.kll

import scala.util.Random
import org.apache.spark.sql.Row
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.{StructType, StructField, IntegerType, BinaryType}

import org.apache.spark.sql.functions_datasketches_kll._
import org.apache.datasketches.kll.KllDoublesSketch
import org.apache.spark.sql.types.KllDoublesSketchType
import org.apache.spark.sql.registrar.KllFunctionRegistry
import org.apache.spark.sql.datasketches.kll.functions._
import org.apache.spark.sql.datasketches.kll.types.KllDoublesSketchType
import org.apache.spark.sql.datasketches.common.SparkSessionManager

class KllTest extends SparkSessionManager {
import spark.implicits._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* limitations under the License.
*/

package org.apache.spark.sql
package org.apache.spark.sql.theta

import org.apache.spark.sql.functions_datasketches_theta._
import org.apache.spark.sql.registrar.ThetaFunctionRegistry
import org.apache.spark.sql.Row
import org.apache.spark.sql.datasketches.common.SparkSessionManager
import org.apache.spark.sql.datasketches.theta.functions._
import org.apache.spark.sql.datasketches.theta.ThetaFunctionRegistry

class ThetaTest extends SparkSessionManager {
import spark.implicits._
Expand Down

0 comments on commit 255b048

Please sign in to comment.