Skip to content
Snippets Groups Projects
  1. Jun 13, 2016
    • Wenchen Fan's avatar
      [SPARK-15887][SQL] Bring back the hive-site.xml support for Spark 2.0 · c4b1ad02
      Wenchen Fan authored
      ## What changes were proposed in this pull request?
      
      Right now, Spark 2.0 does not load hive-site.xml. Based on users' feedback, it seems make sense to still load this conf file.
      
      This PR adds a `hadoopConf` API in `SharedState`, which is `sparkContext.hadoopConfiguration` by default. When users are under hive context, `SharedState.hadoopConf` will load hive-site.xml and append its configs to `sparkContext.hadoopConfiguration`.
      
      When we need to read hadoop config in spark sql, we should call `SessionState.newHadoopConf`, which contains `sparkContext.hadoopConfiguration`, hive-site.xml and sql configs.
      
      ## How was this patch tested?
      
      new test in `HiveDataFrameSuite`
      
      Author: Wenchen Fan <wenchen@databricks.com>
      
      Closes #13611 from cloud-fan/hive-site.
      c4b1ad02
    • Tathagata Das's avatar
      [SPARK-15889][SQL][STREAMING] Add a unique id to ContinuousQuery · c654ae21
      Tathagata Das authored
      ## What changes were proposed in this pull request?
      
      ContinuousQueries have names that are unique across all the active ones. However, when queries are rapidly restarted with same name, it causes races conditions with the listener. A listener event from a stopped query can arrive after the query has been restarted, leading to complexities in monitoring infrastructure.
      
      Along with this change, I have also consolidated all the messy code paths to start queries with different sinks.
      
      ## How was this patch tested?
      Added unit tests, and existing unit tests.
      
      Author: Tathagata Das <tathagata.das1565@gmail.com>
      
      Closes #13613 from tdas/SPARK-15889.
      c654ae21
    • Takeshi YAMAMURO's avatar
      [SPARK-15530][SQL] Set #parallelism for file listing in listLeafFilesInParallel · 5ad4e32d
      Takeshi YAMAMURO authored
      ## What changes were proposed in this pull request?
      This pr is to set the number of parallelism to prevent file listing in `listLeafFilesInParallel` from generating many tasks in case of large #defaultParallelism.
      
      ## How was this patch tested?
      Manually checked
      
      Author: Takeshi YAMAMURO <linguin.m.s@gmail.com>
      
      Closes #13444 from maropu/SPARK-15530.
      5ad4e32d
    • gatorsmile's avatar
      [SPARK-15676][SQL] Disallow Column Names as Partition Columns For Hive Tables · 3b7fb84c
      gatorsmile authored
      #### What changes were proposed in this pull request?
      When creating a Hive Table (not data source tables), a common error users might make is to specify an existing column name as a partition column. Below is what Hive returns in this case:
      ```
      hive> CREATE TABLE partitioned (id bigint, data string) PARTITIONED BY (data string, part string);
      FAILED: SemanticException [Error 10035]: Column repeated in partitioning columns
      ```
      Currently, the error we issued is very confusing:
      ```
      org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:For direct MetaStore DB connections, we don't support retries at the client level.);
      ```
      This PR is to fix the above issue by capturing the usage error in `Parser`.
      
      #### How was this patch tested?
      Added a test case to `DDLCommandSuite`
      
      Author: gatorsmile <gatorsmile@gmail.com>
      
      Closes #13415 from gatorsmile/partitionColumnsInTableSchema.
      3b7fb84c
    • Tathagata Das's avatar
      [HOTFIX][MINOR][SQL] Revert " Standardize 'continuous queries' to 'streaming D… · a6a18a45
      Tathagata Das authored
      This reverts commit d32e2277.
      Broke build - https://amplab.cs.berkeley.edu/jenkins/view/Spark%20QA%20Compile/job/spark-branch-2.0-compile-maven-hadoop-2.3/326/console
      
      Author: Tathagata Das <tathagata.das1565@gmail.com>
      
      Closes #13645 from tdas/build-break.
      a6a18a45
    • Liwei Lin's avatar
      [MINOR][SQL] Standardize 'continuous queries' to 'streaming Datasets/DataFrames' · d32e2277
      Liwei Lin authored
      ## What changes were proposed in this pull request?
      
      This patch does some replacing (as `streaming Datasets/DataFrames` is the term we've chosen in [SPARK-15593](https://github.com/apache/spark/commit/00c310133df4f3893dd90d801168c2ab9841b102)):
       - `continuous queries` -> `streaming Datasets/DataFrames`
       - `non-continuous queries` -> `non-streaming Datasets/DataFrames`
      
      This patch also adds `test("check foreach() can only be called on streaming Datasets/DataFrames")`.
      
      ## How was this patch tested?
      
      N/A
      
      Author: Liwei Lin <lwlin7@gmail.com>
      
      Closes #13595 from lw-lin/continuous-queries-to-streaming-dss-dfs.
      d32e2277
    • Prashant Sharma's avatar
      [SPARK-15697][REPL] Unblock some of the useful repl commands. · 4134653e
      Prashant Sharma authored
      ## What changes were proposed in this pull request?
      
      Unblock some of the useful repl commands. like, "implicits", "javap", "power", "type", "kind". As they are useful and fully functional and part of scala/scala project, I see no harm in having them either.
      
      Verbatim paste form JIRA description.
      "implicits", "javap", "power", "type", "kind" commands in repl are blocked. However, they work fine in all cases I have tried. It is clear we don't support them as they are part of the scala/scala repl project. What is the harm in unblocking them, given they are useful ?
      In previous versions of spark we disabled these commands because it was difficult to support them without customization and the associated maintenance. Since the code base of scala repl was actually ported and maintained under spark source. Now that is not the situation and one can benefit from these commands in Spark REPL as much as in scala repl.
      
      ## How was this patch tested?
      Existing tests and manual, by trying out all of the above commands.
      
      P.S. Symantics of reset are to be discussed in a separate issue.
      
      Author: Prashant Sharma <prashsh1@in.ibm.com>
      
      Closes #13437 from ScrapCodes/SPARK-15697/repl-unblock-commands.
      4134653e
    • Dongjoon Hyun's avatar
      [SPARK-15913][CORE] Dispatcher.stopped should be enclosed by synchronized block. · 938434dc
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      
      `Dispatcher.stopped` is guarded by `this`, but it is used without synchronization in `postMessage` function. This PR fixes this and also the exception message became more accurate.
      
      ## How was this patch tested?
      
      Pass the existing Jenkins tests.
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #13634 from dongjoon-hyun/SPARK-15913.
      938434dc
    • Wenchen Fan's avatar
      [SPARK-15814][SQL] Aggregator can return null result · cd47e233
      Wenchen Fan authored
      ## What changes were proposed in this pull request?
      
      It's similar to the bug fixed in https://github.com/apache/spark/pull/13425, we should consider null object and wrap the `CreateStruct` with `If` to do null check.
      
      This PR also improves the test framework to test the objects of `Dataset[T]` directly, instead of calling `toDF` and compare the rows.
      
      ## How was this patch tested?
      
      new test in `DatasetAggregatorSuite`
      
      Author: Wenchen Fan <wenchen@databricks.com>
      
      Closes #13553 from cloud-fan/agg-null.
      cd47e233
    • Peter Ableda's avatar
      [SPARK-15813] Improve Canceling log message to make it less ambiguous · d681742b
      Peter Ableda authored
      ## What changes were proposed in this pull request?
      Add new desired executor number to make the log message less ambiguous.
      
      ## How was this patch tested?
      This is a trivial change
      
      Author: Peter Ableda <abledapeter@gmail.com>
      
      Closes #13552 from peterableda/patch-1.
      d681742b
  2. Jun 12, 2016
    • Wenchen Fan's avatar
      [SPARK-15898][SQL] DataFrameReader.text should return DataFrame · e2ab79d5
      Wenchen Fan authored
      ## What changes were proposed in this pull request?
      
      We want to maintain API compatibility for DataFrameReader.text, and will introduce a new API called DataFrameReader.textFile which returns Dataset[String].
      
      affected PRs:
      https://github.com/apache/spark/pull/11731
      https://github.com/apache/spark/pull/13104
      https://github.com/apache/spark/pull/13184
      
      ## How was this patch tested?
      
      N/A
      
      Author: Wenchen Fan <wenchen@databricks.com>
      
      Closes #13604 from cloud-fan/revert.
      e2ab79d5
    • Herman van Hövell tot Westerflier's avatar
      [SPARK-15370][SQL] Fix count bug · 1f8f2b5c
      Herman van Hövell tot Westerflier authored
      # What changes were proposed in this pull request?
      This pull request fixes the COUNT bug in the `RewriteCorrelatedScalarSubquery` rule.
      
      After this change, the rule tests the expression at the root of the correlated subquery to determine whether the expression returns `NULL` on empty input. If the expression does not return `NULL`, the rule generates additional logic in the `Project` operator above the rewritten subquery. This additional logic intercepts `NULL` values coming from the outer join and replaces them with the value that the subquery's expression would return on empty input.
      
      This PR takes over https://github.com/apache/spark/pull/13155. It only fixes an issue with `Literal` construction and style issues.  All credits should go frreiss.
      
      # How was this patch tested?
      Added regression tests to cover all branches of the updated rule (see changes to `SubquerySuite`).
      Ran all existing automated regression tests after merging with latest trunk.
      
      Author: frreiss <frreiss@us.ibm.com>
      Author: Herman van Hovell <hvanhovell@databricks.com>
      
      Closes #13629 from hvanhovell/SPARK-15370-cleanup.
      1f8f2b5c
    • Wenchen Fan's avatar
    • Takuya UESHIN's avatar
      [SPARK-15870][SQL] DataFrame can't execute after uncacheTable. · caebd7f2
      Takuya UESHIN authored
      ## What changes were proposed in this pull request?
      
      If a cached `DataFrame` executed more than once and then do `uncacheTable` like the following:
      
      ```
          val selectStar = sql("SELECT * FROM testData WHERE key = 1")
          selectStar.createOrReplaceTempView("selectStar")
      
          spark.catalog.cacheTable("selectStar")
          checkAnswer(
            selectStar,
            Seq(Row(1, "1")))
      
          spark.catalog.uncacheTable("selectStar")
          checkAnswer(
            selectStar,
            Seq(Row(1, "1")))
      ```
      
      , then the uncached `DataFrame` can't execute because of `Task not serializable` exception like:
      
      ```
      org.apache.spark.SparkException: Task not serializable
      	at org.apache.spark.util.ClosureCleaner$.ensureSerializable(ClosureCleaner.scala:298)
      	at org.apache.spark.util.ClosureCleaner$.org$apache$spark$util$ClosureCleaner$$clean(ClosureCleaner.scala:288)
      	at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:108)
      	at org.apache.spark.SparkContext.clean(SparkContext.scala:2038)
      	at org.apache.spark.SparkContext.runJob(SparkContext.scala:1897)
      	at org.apache.spark.SparkContext.runJob(SparkContext.scala:1912)
      	at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:884)
      	at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
      	at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
      	at org.apache.spark.rdd.RDD.withScope(RDD.scala:357)
      	at org.apache.spark.rdd.RDD.collect(RDD.scala:883)
      	at org.apache.spark.sql.execution.SparkPlan.executeCollect(SparkPlan.scala:290)
      ...
      Caused by: java.lang.UnsupportedOperationException: Accumulator must be registered before send to executor
      	at org.apache.spark.util.AccumulatorV2.writeReplace(AccumulatorV2.scala:153)
      	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1118)
      	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1136)
      	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
      	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
      	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
      ...
      ```
      
      Notice that `DataFrame` uncached with `DataFrame.unpersist()` works, but with `spark.catalog.uncacheTable` doesn't work.
      
      This pr reverts a part of cf38fe04 not to unregister `batchStats` accumulator, which is not needed to be unregistered here because it will be done by `ContextCleaner` after it is collected by GC.
      
      ## How was this patch tested?
      
      Added a test to check if DataFrame can execute after uncacheTable and other existing tests.
      But I made a test to check if the accumulator was cleared as `ignore` because the test would be flaky.
      
      Author: Takuya UESHIN <ueshin@happy-camper.st>
      
      Closes #13596 from ueshin/issues/SPARK-15870.
      caebd7f2
    • Herman van Hovell's avatar
      [SPARK-15370][SQL] Revert PR "Update RewriteCorrelatedSuquery rule" · 20b8f2c3
      Herman van Hovell authored
      This reverts commit 9770f6ee.
      
      Author: Herman van Hovell <hvanhovell@databricks.com>
      
      Closes #13626 from hvanhovell/SPARK-15370-revert.
      20b8f2c3
    • hyukjinkwon's avatar
      [SPARK-15892][ML] Incorrectly merged AFTAggregator with zero total count · e3554605
      hyukjinkwon authored
      ## What changes were proposed in this pull request?
      
      Currently, `AFTAggregator` is not being merged correctly. For example, if there is any single empty partition in the data, this creates an `AFTAggregator` with zero total count which causes the exception below:
      
      ```
      IllegalArgumentException: u'requirement failed: The number of instances should be greater than 0.0, but got 0.'
      ```
      
      Please see [AFTSurvivalRegression.scala#L573-L575](https://github.com/apache/spark/blob/6ecedf39b44c9acd58cdddf1a31cf11e8e24428c/mllib/src/main/scala/org/apache/spark/ml/regression/AFTSurvivalRegression.scala#L573-L575) as well.
      
      Just to be clear, the python example `aft_survival_regression.py` seems using 5 rows. So, if there exist partitions more than 5, it throws the exception above since it contains empty partitions which results in an incorrectly merged `AFTAggregator`.
      
      Executing `bin/spark-submit examples/src/main/python/ml/aft_survival_regression.py` on a machine with CPUs more than 5 is being failed because it creates tasks with some empty partitions with defualt  configurations (AFAIK, it sets the parallelism level to the number of CPU cores).
      
      ## How was this patch tested?
      
      An unit test in `AFTSurvivalRegressionSuite.scala` and manually tested by `bin/spark-submit examples/src/main/python/ml/aft_survival_regression.py`.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      Author: Hyukjin Kwon <gurwls223@gmail.com>
      
      Closes #13619 from HyukjinKwon/SPARK-15892.
      e3554605
    • Ioana Delaney's avatar
      [SPARK-15832][SQL] Embedded IN/EXISTS predicate subquery throws TreeNodeException · 0ff8a68b
      Ioana Delaney authored
      ## What changes were proposed in this pull request?
      Queries with embedded existential sub-query predicates throws exception when building the physical plan.
      
      Example failing query:
      ```SQL
      scala> Seq((1, 1), (2, 2)).toDF("c1", "c2").createOrReplaceTempView("t1")
      scala> Seq((1, 1), (2, 2)).toDF("c1", "c2").createOrReplaceTempView("t2")
      scala> sql("select c1 from t1 where (case when c2 in (select c2 from t2) then 2 else 3 end) IN (select c2 from t1)").show()
      
      Binding attribute, tree: c2#239
      org.apache.spark.sql.catalyst.errors.package$TreeNodeException: Binding attribute, tree: c2#239
        at org.apache.spark.sql.catalyst.errors.package$.attachTree(package.scala:50)
        at org.apache.spark.sql.catalyst.expressions.BindReferences$$anonfun$bindReference$1.applyOrElse(BoundAttribute.scala:88)
      
        ...
        at org.apache.spark.sql.catalyst.expressions.BindReferences$.bindReference(BoundAttribute.scala:87)
        at org.apache.spark.sql.execution.joins.HashJoin$$anonfun$4.apply(HashJoin.scala:66)
        at org.apache.spark.sql.execution.joins.HashJoin$$anonfun$4.apply(HashJoin.scala:66)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.immutable.List.foreach(List.scala:381)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
        at scala.collection.immutable.List.map(List.scala:285)
        at org.apache.spark.sql.execution.joins.HashJoin$class.org$apache$spark$sql$execution$joins$HashJoin$$x$8(HashJoin.scala:66)
        at org.apache.spark.sql.execution.joins.BroadcastHashJoinExec.org$apache$spark$sql$execution$joins$HashJoin$$x$8$lzycompute(BroadcastHashJoinExec.scala:38)
        at org.apache.spark.sql.execution.joins.BroadcastHashJoinExec.org$apache$spark$sql$execution$joins$HashJoin$$x$8(BroadcastHashJoinExec.scala:38)
        at org.apache.spark.sql.execution.joins.HashJoin$class.buildKeys(HashJoin.scala:63)
        at org.apache.spark.sql.execution.joins.BroadcastHashJoinExec.buildKeys$lzycompute(BroadcastHashJoinExec.scala:38)
        at org.apache.spark.sql.execution.joins.BroadcastHashJoinExec.buildKeys(BroadcastHashJoinExec.scala:38)
        at org.apache.spark.sql.execution.joins.BroadcastHashJoinExec.requiredChildDistribution(BroadcastHashJoinExec.scala:52)
      ```
      
      **Problem description:**
      When the left hand side expression of an existential sub-query predicate contains another embedded sub-query predicate, the RewritePredicateSubquery optimizer rule does not resolve the embedded sub-query expressions into existential joins.For example, the above query has the following optimized plan, which fails during physical plan build.
      
      ```SQL
      == Optimized Logical Plan ==
      Project [_1#224 AS c1#227]
      +- Join LeftSemi, (CASE WHEN predicate-subquery#255 [(_2#225 = c2#239)] THEN 2 ELSE 3 END = c2#228#262)
         :  +- SubqueryAlias predicate-subquery#255 [(_2#225 = c2#239)]
         :     +- LocalRelation [c2#239]
         :- LocalRelation [_1#224, _2#225]
         +- LocalRelation [c2#228#262]
      
      == Physical Plan ==
      org.apache.spark.sql.catalyst.errors.package$TreeNodeException: Binding attribute, tree: c2#239
      ```
      
      **Solution:**
      In RewritePredicateSubquery, before rewriting the outermost predicate sub-query, resolve any embedded existential sub-queries. The Optimized plan for the above query after the changes looks like below.
      
      ```SQL
      == Optimized Logical Plan ==
      Project [_1#224 AS c1#227]
      +- Join LeftSemi, (CASE WHEN exists#285 THEN 2 ELSE 3 END = c2#228#284)
         :- Join ExistenceJoin(exists#285), (_2#225 = c2#239)
         :  :- LocalRelation [_1#224, _2#225]
         :  +- LocalRelation [c2#239]
         +- LocalRelation [c2#228#284]
      
      == Physical Plan ==
      *Project [_1#224 AS c1#227]
      +- *BroadcastHashJoin [CASE WHEN exists#285 THEN 2 ELSE 3 END], [c2#228#284], LeftSemi, BuildRight
         :- *BroadcastHashJoin [_2#225], [c2#239], ExistenceJoin(exists#285), BuildRight
         :  :- LocalTableScan [_1#224, _2#225]
         :  +- BroadcastExchange HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)))
         :     +- LocalTableScan [c2#239]
         +- BroadcastExchange HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)))
            +- LocalTableScan [c2#228#284]
            +- LocalTableScan [c222#36], [[111],[222]]
      ```
      
      ## How was this patch tested?
      Added new test cases in SubquerySuite.scala
      
      Author: Ioana Delaney <ioanamdelaney@gmail.com>
      
      Closes #13570 from ioana-delaney/fixEmbedSubPredV1.
      0ff8a68b
    • frreiss's avatar
      [SPARK-15370][SQL] Update RewriteCorrelatedScalarSubquery rule to fix COUNT bug · 9770f6ee
      frreiss authored
      ## What changes were proposed in this pull request?
      This pull request fixes the COUNT bug in the `RewriteCorrelatedScalarSubquery` rule.
      
      After this change, the rule tests the expression at the root of the correlated subquery to determine whether the expression returns NULL on empty input. If the expression does not return NULL, the rule generates additional logic in the Project operator above the rewritten subquery.  This additional logic intercepts NULL values coming from the outer join and replaces them with the value that the subquery's expression would return on empty input.
      
      ## How was this patch tested?
      Added regression tests to cover all branches of the updated rule (see changes to `SubquerySuite.scala`).
      Ran all existing automated regression tests after merging with latest trunk.
      
      Author: frreiss <frreiss@us.ibm.com>
      
      Closes #13155 from frreiss/master.
      9770f6ee
    • Sean Owen's avatar
      [SPARK-15876][CORE] Remove support for "zk://" master URL · 0a6f0908
      Sean Owen authored
      ## What changes were proposed in this pull request?
      
      Remove deprecated support for `zk://` master (`mesos://zk//` remains supported)
      
      ## How was this patch tested?
      
      Jenkins
      
      Author: Sean Owen <sowen@cloudera.com>
      
      Closes #13625 from srowen/SPARK-15876.
      0a6f0908
    • Sean Owen's avatar
      [SPARK-15086][CORE][STREAMING] Deprecate old Java accumulator API · f51dfe61
      Sean Owen authored
      ## What changes were proposed in this pull request?
      
      - Deprecate old Java accumulator API; should use Scala now
      - Update Java tests and examples
      - Don't bother testing old accumulator API in Java 8 (too)
      - (fix a misspelling too)
      
      ## How was this patch tested?
      
      Jenkins tests
      
      Author: Sean Owen <sowen@cloudera.com>
      
      Closes #13606 from srowen/SPARK-15086.
      f51dfe61
    • bomeng's avatar
      [SPARK-15806][DOCUMENTATION] update doc for SPARK_MASTER_IP · 50248dcf
      bomeng authored
      ## What changes were proposed in this pull request?
      
      SPARK_MASTER_IP is a deprecated environment variable. It is replaced by SPARK_MASTER_HOST according to MasterArguments.scala.
      
      ## How was this patch tested?
      
      Manually verified.
      
      Author: bomeng <bmeng@us.ibm.com>
      
      Closes #13543 from bomeng/SPARK-15806.
      50248dcf
    • bomeng's avatar
      [SPARK-15781][DOCUMENTATION] remove deprecated environment variable doc · 3fd3ee03
      bomeng authored
      ## What changes were proposed in this pull request?
      
      Like `SPARK_JAVA_OPTS` and `SPARK_CLASSPATH`, we will remove the document for `SPARK_WORKER_INSTANCES` to discourage user not to use them. If they are actually used, SparkConf will show a warning message as before.
      
      ## How was this patch tested?
      
      Manually tested.
      
      Author: bomeng <bmeng@us.ibm.com>
      
      Closes #13533 from bomeng/SPARK-15781.
      3fd3ee03
    • Imran Rashid's avatar
      [SPARK-15878][CORE][TEST] fix cleanup in EventLoggingListenerSuite and ReplayListenerSuite · 8cc22b00
      Imran Rashid authored
      ## What changes were proposed in this pull request?
      
      These tests weren't properly using `LocalSparkContext` so weren't cleaning up correctly when tests failed.
      
      ## How was this patch tested?
      
      Jenkins.
      
      Author: Imran Rashid <irashid@cloudera.com>
      
      Closes #13602 from squito/SPARK-15878_cleanup_replaylistener.
      8cc22b00
    • hyukjinkwon's avatar
      [SPARK-15840][SQL] Add two missing options in documentation and some option related changes · 9e204c62
      hyukjinkwon authored
      ## What changes were proposed in this pull request?
      
      This PR
      
      1. Adds the documentations for some missing options, `inferSchema` and `mergeSchema` for Python and Scala.
      
      2. Fiixes `[[DataFrame]]` to ```:class:`DataFrame` ``` so that this can be shown
      
        - from
          ![2016-06-09 9 31 16](https://cloud.githubusercontent.com/assets/6477701/15929721/8b864734-2e89-11e6-83f6-207527de4ac9.png)
      
        - to (with class link)
          ![2016-06-09 9 31 00](https://cloud.githubusercontent.com/assets/6477701/15929717/8a03d728-2e89-11e6-8a3f-08294964db22.png)
      
        (Please refer [the latest documentation](https://people.apache.org/~pwendell/spark-nightly/spark-master-docs/latest/api/python/pyspark.sql.html))
      
      3. Moves `mergeSchema` option to `ParquetOptions` with removing unused options, `metastoreSchema` and `metastoreTableName`.
      
        They are not used anymore. They were removed in https://github.com/apache/spark/commit/e720dda42e806229ccfd970055c7b8a93eb447bf and there are no use cases as below:
      
        ```bash
        grep -r -e METASTORE_SCHEMA -e \"metastoreSchema\" -e \"metastoreTableName\" -e METASTORE_TABLE_NAME .
        ```
      
        ```
        ./sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFileFormat.scala:  private[sql] val METASTORE_SCHEMA = "metastoreSchema"
        ./sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFileFormat.scala:  private[sql] val METASTORE_TABLE_NAME = "metastoreTableName"
        ./sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala:        ParquetFileFormat.METASTORE_TABLE_NAME -> TableIdentifier(
      ```
      
        It only sets `metastoreTableName` in the last case but does not use the table name.
      
      4. Sets the correct default values (in the documentation) for `compression` option for ORC(`snappy`, see [OrcOptions.scala#L33-L42](https://github.com/apache/spark/blob/3ded5bc4db2badc9ff49554e73421021d854306b/sql/hive/src/main/scala/org/apache/spark/sql/hive/orc/OrcOptions.scala#L33-L42)) and Parquet(`the value specified in SQLConf`, see [ParquetOptions.scala#L38-L47](https://github.com/apache/spark/blob/3ded5bc4db2badc9ff49554e73421021d854306b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetOptions.scala#L38-L47)) and `columnNameOfCorruptRecord` for JSON(`the value specified in SQLConf`, see [JsonFileFormat.scala#L53-L55](https://github.com/apache/spark/blob/4538443e276597530a27c6922e48503677b13956/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/json/JsonFileFormat.scala#L53-L55) and [JsonFileFormat.scala#L105-L106](https://github.com/apache/spark/blob/4538443e276597530a27c6922e48503677b13956/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/json/JsonFileFormat.scala#L105-L106)).
      
      ## How was this patch tested?
      
      Existing tests should cover this.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      Author: Hyukjin Kwon <gurwls223@gmail.com>
      
      Closes #13576 from HyukjinKwon/SPARK-15840.
      9e204c62
    • Eric Liang's avatar
      [SPARK-15860] Metrics for codegen size and perf · e1f986c7
      Eric Liang authored
      ## What changes were proposed in this pull request?
      
      Adds codahale metrics for the codegen source text size and how long it takes to compile. The size is particularly interesting, since the JVM does have hard limits on how large methods can get.
      
      To simplify, I added the metrics under a statically-initialized source that is always registered with SparkEnv.
      
      ## How was this patch tested?
      
      Unit tests
      
      Author: Eric Liang <ekl@databricks.com>
      
      Closes #13586 from ericl/spark-15860.
      e1f986c7
  3. Jun 11, 2016
    • Dongjoon Hyun's avatar
      [SPARK-15807][SQL] Support varargs for dropDuplicates in Dataset/DataFrame · 3fd2ff4d
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      This PR adds `varargs`-types `dropDuplicates` functions in `Dataset/DataFrame`. Currently, `dropDuplicates` supports only `Seq` or `Array`.
      
      **Before**
      ```scala
      scala> val ds = spark.createDataFrame(Seq(("a", 1), ("b", 2), ("a", 2)))
      ds: org.apache.spark.sql.DataFrame = [_1: string, _2: int]
      
      scala> ds.dropDuplicates(Seq("_1", "_2"))
      res0: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [_1: string, _2: int]
      
      scala> ds.dropDuplicates("_1", "_2")
      <console>:26: error: overloaded method value dropDuplicates with alternatives:
        (colNames: Array[String])org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
        (colNames: Seq[String])org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
        ()org.apache.spark.sql.Dataset[org.apache.spark.sql.Row]
       cannot be applied to (String, String)
             ds.dropDuplicates("_1", "_2")
                ^
      ```
      
      **After**
      ```scala
      scala> val ds = spark.createDataFrame(Seq(("a", 1), ("b", 2), ("a", 2)))
      ds: org.apache.spark.sql.DataFrame = [_1: string, _2: int]
      
      scala> ds.dropDuplicates("_1", "_2")
      res0: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [_1: string, _2: int]
      ```
      
      ## How was this patch tested?
      
      Pass the Jenkins tests with new testcases.
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #13545 from dongjoon-hyun/SPARK-15807.
      3fd2ff4d
    • Eric Liang's avatar
      [SPARK-14851][CORE] Support radix sort with nullable longs · c06c58bb
      Eric Liang authored
      ## What changes were proposed in this pull request?
      
      This adds support for radix sort of nullable long fields. When a sort field is null and radix sort is enabled, we keep nulls in a separate region of the sort buffer so that radix sort does not need to deal with them. This also has performance benefits when sorting smaller integer types, since the current representation of nulls in two's complement (Long.MIN_VALUE) otherwise forces a full-width radix sort.
      
      This strategy for nulls does mean the sort is no longer stable. cc davies
      
      ## How was this patch tested?
      
      Existing randomized sort tests for correctness. I also tested some TPCDS queries and there does not seem to be any significant regression for non-null sorts.
      
      Some test queries (best of 5 runs each).
      Before change:
      scala> val start = System.nanoTime; spark.range(5000000).selectExpr("if(id > 5, cast(hash(id) as long), NULL) as h").coalesce(1).orderBy("h").collect(); (System.nanoTime - start) / 1e6
      start: Long = 3190437233227987
      res3: Double = 4716.471091
      
      After change:
      scala> val start = System.nanoTime; spark.range(5000000).selectExpr("if(id > 5, cast(hash(id) as long), NULL) as h").coalesce(1).orderBy("h").collect(); (System.nanoTime - start) / 1e6
      start: Long = 3190367870952791
      res4: Double = 2981.143045
      
      Author: Eric Liang <ekl@databricks.com>
      
      Closes #13161 from ericl/sc-2998.
      c06c58bb
    • Wenchen Fan's avatar
      [SPARK-15856][SQL] Revert API breaking changes made in SQLContext.range · 75705e8d
      Wenchen Fan authored
      ## What changes were proposed in this pull request?
      
      It's easy for users to call `range(...).as[Long]` to get typed Dataset, and don't worth an API breaking change. This PR reverts it.
      
      ## How was this patch tested?
      
      N/A
      
      Author: Wenchen Fan <wenchen@databricks.com>
      
      Closes #13605 from cloud-fan/range.
      75705e8d
    • Eric Liang's avatar
      [SPARK-15881] Update microbenchmark results for WideSchemaBenchmark · 5bb4564c
      Eric Liang authored
      ## What changes were proposed in this pull request?
      
      These were not updated after performance improvements. To make updating them easier, I also moved the results from inline comments out into a file, which is auto-generated when the benchmark is re-run.
      
      Author: Eric Liang <ekl@databricks.com>
      
      Closes #13607 from ericl/sc-3538.
      5bb4564c
    • Takeshi YAMAMURO's avatar
      [SPARK-15585][SQL] Add doc for turning off quotations · cb5d933d
      Takeshi YAMAMURO authored
      ## What changes were proposed in this pull request?
      This pr is to add doc for turning off quotations because this behavior is different from `com.databricks.spark.csv`.
      
      ## How was this patch tested?
      Check behavior  to put an empty string in csv options.
      
      Author: Takeshi YAMAMURO <linguin.m.s@gmail.com>
      
      Closes #13616 from maropu/SPARK-15585-2.
      cb5d933d
    • Dongjoon Hyun's avatar
      [SPARK-15883][MLLIB][DOCS] Fix broken links in mllib documents · ad102af1
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      
      This issue fixes all broken links on Spark 2.0 preview MLLib documents. Also, this contains some editorial change.
      
      **Fix broken links**
        * mllib-data-types.md
        * mllib-decision-tree.md
        * mllib-ensembles.md
        * mllib-feature-extraction.md
        * mllib-pmml-model-export.md
        * mllib-statistics.md
      
      **Fix malformed section header and scala coding style**
        * mllib-linear-methods.md
      
      **Replace indirect forward links with direct one**
        * ml-classification-regression.md
      
      ## How was this patch tested?
      
      Manual tests (with `cd docs; jekyll build`.)
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #13608 from dongjoon-hyun/SPARK-15883.
      ad102af1
    • Sean Owen's avatar
      [SPARK-15879][DOCS][UI] Update logo in UI and docs to add "Apache" · 3761330d
      Sean Owen authored
      ## What changes were proposed in this pull request?
      
      Use new Spark logo including "Apache" (now, with crushed PNGs). Remove old unreferenced logo files.
      
      ## How was this patch tested?
      
      Manual check of generated HTML site and Spark UI. I searched for references to the deleted files to make sure they were not used.
      
      Author: Sean Owen <sowen@cloudera.com>
      
      Closes #13609 from srowen/SPARK-15879.
      3761330d
  4. Jun 10, 2016
    • Davies Liu's avatar
      [SPARK-15759] [SQL] Fallback to non-codegen when fail to compile generated code · 7504bc73
      Davies Liu authored
      ## What changes were proposed in this pull request?
      
      In case of any bugs in whole-stage codegen, the generated code can't be compiled, we should fallback to non-codegen to make sure that query could run.
      
      The batch mode of new parquet reader depends on codegen, can't be easily switched to non-batch mode, so we still use codegen for batched scan (for parquet). Because it only support primitive types and the number of columns is less than spark.sql.codegen.maxFields (100), it should not fail.
      
      This could be configurable by `spark.sql.codegen.fallback`
      
      ## How was this patch tested?
      
      Manual test it with buggy operator, it worked well.
      
      Author: Davies Liu <davies@databricks.com>
      
      Closes #13501 from davies/codegen_fallback.
      7504bc73
    • Sameer Agarwal's avatar
      [SPARK-15678] Add support to REFRESH data source paths · 468da03e
      Sameer Agarwal authored
      ## What changes were proposed in this pull request?
      
      Spark currently incorrectly continues to use cached data even if the underlying data is overwritten.
      
      Current behavior:
      ```scala
      val dir = "/tmp/test"
      sqlContext.range(1000).write.mode("overwrite").parquet(dir)
      val df = sqlContext.read.parquet(dir).cache()
      df.count() // outputs 1000
      sqlContext.range(10).write.mode("overwrite").parquet(dir)
      sqlContext.read.parquet(dir).count() // outputs 1000 <---- We are still using the cached dataset
      ```
      
      This patch fixes this bug by adding support for `REFRESH path` that invalidates and refreshes all the cached data (and the associated metadata) for any dataframe that contains the given data source path.
      
      Expected behavior:
      ```scala
      val dir = "/tmp/test"
      sqlContext.range(1000).write.mode("overwrite").parquet(dir)
      val df = sqlContext.read.parquet(dir).cache()
      df.count() // outputs 1000
      sqlContext.range(10).write.mode("overwrite").parquet(dir)
      spark.catalog.refreshResource(dir)
      sqlContext.read.parquet(dir).count() // outputs 10 <---- We are not using the cached dataset
      ```
      
      ## How was this patch tested?
      
      Unit tests for overwrites and appends in `ParquetQuerySuite` and `CachedTableSuite`.
      
      Author: Sameer Agarwal <sameer@databricks.com>
      
      Closes #13566 from sameeragarwal/refresh-path-2.
      468da03e
    • Cheng Lian's avatar
    • hyukjinkwon's avatar
      [SPARK-14615][ML][FOLLOWUP] Fix Python examples to use the new ML Vector and... · 99f3c827
      hyukjinkwon authored
      [SPARK-14615][ML][FOLLOWUP] Fix Python examples to use the new ML Vector and Matrix APIs in the ML pipeline based algorithms
      
      ## What changes were proposed in this pull request?
      
      This PR fixes Python examples to use the new ML Vector and Matrix APIs in the ML pipeline based algorithms.
      
      I firstly executed this shell command, `grep -r "from pyspark.mllib" .` and then executed them all.
      Some of tests in `ml` produced the error messages as below:
      
      ```
      pyspark.sql.utils.IllegalArgumentException: u'requirement failed: Input type must be VectorUDT but got org.apache.spark.mllib.linalg.VectorUDTf71b0bce.'
      ```
      
      So, I fixed them to use new ones just identically with some Python tests fixed in https://github.com/apache/spark/pull/12627
      
      ## How was this patch tested?
      
      Manually tested for all the examples listed by `grep -r "from pyspark.mllib" .`.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #13393 from HyukjinKwon/SPARK-14615.
      99f3c827
    • Liang-Chi Hsieh's avatar
      [SPARK-15639][SQL] Try to push down filter at RowGroups level for parquet reader · bba5d799
      Liang-Chi Hsieh authored
      ## What changes were proposed in this pull request?
      
      The base class `SpecificParquetRecordReaderBase` used for vectorized parquet reader will try to get pushed-down filters from the given configuration. This pushed-down filters are used for RowGroups-level filtering. However, we don't set up the filters to push down into the configuration. In other words, the filters are not actually pushed down to do RowGroups-level filtering. This patch is to fix this and tries to set up the filters for pushing down to configuration for the reader.
      
      ## How was this patch tested?
      Existing tests should be passed.
      
      Author: Liang-Chi Hsieh <simonh@tw.ibm.com>
      
      Closes #13371 from viirya/vectorized-reader-push-down-filter.
      bba5d799
    • Narine Kokhlikyan's avatar
      [SPARK-15884][SPARKR][SQL] Overriding stringArgs in MapPartitionsInR · 54f758b5
      Narine Kokhlikyan authored
      ## What changes were proposed in this pull request?
      
      As discussed in https://github.com/apache/spark/pull/12836
      we need to override stringArgs method in MapPartitionsInR in order to avoid too large strings generated by "stringArgs" method based on the input arguments.
      
      In this case exclude some of the input arguments: serialized R objects.
      
      ## How was this patch tested?
      Existing test cases
      
      Author: Narine Kokhlikyan <narine.kokhlikyan@gmail.com>
      
      Closes #13610 from NarineK/dapply_MapPartitionsInR_stringArgs.
      54f758b5
    • Dongjoon Hyun's avatar
      [SPARK-15773][CORE][EXAMPLE] Avoid creating local variable `sc` in examples if possible · 2022afe5
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      
      Instead of using local variable `sc` like the following example, this PR uses `spark.sparkContext`. This makes examples more concise, and also fixes some misleading, i.e., creating SparkContext from SparkSession.
      ```
      -    println("Creating SparkContext")
      -    val sc = spark.sparkContext
      -
           println("Writing local file to DFS")
           val dfsFilename = dfsDirPath + "/dfs_read_write_test"
      -    val fileRDD = sc.parallelize(fileContents)
      +    val fileRDD = spark.sparkContext.parallelize(fileContents)
      ```
      
      This will change 12 files (+30 lines, -52 lines).
      
      ## How was this patch tested?
      
      Manual.
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #13520 from dongjoon-hyun/SPARK-15773.
      2022afe5
    • Sela's avatar
      [SPARK-15489][SQL] Dataset kryo encoder won't load custom user settings · 127a6678
      Sela authored
      ## What changes were proposed in this pull request?
      
      Serializer instantiation will consider existing SparkConf
      
      ## How was this patch tested?
      manual test with `ImmutableList` (Guava) and `kryo-serializers`'s `Immutable*Serializer` implementations.
      
      Added Test Suite.
      
      (If this patch involves UI changes, please attach a screenshot; otherwise, remove this)
      
      Author: Sela <ansela@paypal.com>
      
      Closes #13424 from amitsela/SPARK-15489.
      127a6678
Loading