Skip to content
Snippets Groups Projects
  1. Sep 29, 2016
    • Bryan Cutler's avatar
      [SPARK-17697][ML] Fixed bug in summary calculations that pattern match against... · 2f739567
      Bryan Cutler authored
      [SPARK-17697][ML] Fixed bug in summary calculations that pattern match against label without casting
      
      ## What changes were proposed in this pull request?
      In calling LogisticRegression.evaluate and GeneralizedLinearRegression.evaluate using a Dataset where the Label is not of a double type, calculations pattern match against a double and throw a MatchError.  This fix casts the Label column to a DoubleType to ensure there is no MatchError.
      
      ## How was this patch tested?
      Added unit tests to call evaluate with a dataset that has Label as other numeric types.
      
      Author: Bryan Cutler <cutlerb@gmail.com>
      
      Closes #15288 from BryanCutler/binaryLOR-numericCheck-SPARK-17697.
      2f739567
    • Dongjoon Hyun's avatar
      [SPARK-17412][DOC] All test should not be run by `root` or any admin user · 39eb3bb1
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      
      `FsHistoryProviderSuite` fails if `root` user runs it. The test case **SPARK-3697: ignore directories that cannot be read** depends on `setReadable(false, false)` to make test data files and expects the number of accessible files is 1. But, `root` can access all files, so it returns 2.
      
      This PR adds the assumption explicitly on doc. `building-spark.md`.
      
      ## How was this patch tested?
      
      This is a documentation change.
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #15291 from dongjoon-hyun/SPARK-17412.
      39eb3bb1
    • Imran Rashid's avatar
      [SPARK-17676][CORE] FsHistoryProvider should ignore hidden files · 3993ebca
      Imran Rashid authored
      ## What changes were proposed in this pull request?
      
      FsHistoryProvider was writing a hidden file (to check the fs's clock).
      Even though it deleted the file immediately, sometimes another thread
      would try to scan the files on the fs in-between, and then there would
      be an error msg logged which was very misleading for the end-user.
      (The logged error was harmless, though.)
      
      ## How was this patch tested?
      
      I added one unit test, but to be clear, that test was passing before.  The actual change in behavior in that test is just logging (after the change, there is no more logged error), which I just manually verified.
      
      Author: Imran Rashid <irashid@cloudera.com>
      
      Closes #15250 from squito/SPARK-17676.
      3993ebca
    • Bjarne Fruergaard's avatar
      [SPARK-17721][MLLIB][ML] Fix for multiplying transposed SparseMatrix with SparseVector · 29396e7d
      Bjarne Fruergaard authored
      ## What changes were proposed in this pull request?
      
      * changes the implementation of gemv with transposed SparseMatrix and SparseVector both in mllib-local and mllib (identical)
      * adds a test that was failing before this change, but succeeds with these changes.
      
      The problem in the previous implementation was that it only increments `i`, that is enumerating the columns of a row in the SparseMatrix, when the row-index of the vector matches the column-index of the SparseMatrix. In cases where a particular row of the SparseMatrix has non-zero values at column-indices lower than corresponding non-zero row-indices of the SparseVector, the non-zero values of the SparseVector are enumerated without ever matching the column-index at index `i` and the remaining column-indices i+1,...,indEnd-1 are never attempted. The test cases in this PR illustrate this issue.
      
      ## How was this patch tested?
      
      I have run the specific `gemv` tests in both mllib-local and mllib. I am currently still running `./dev/run-tests`.
      
      ## ___
      As per instructions, I hereby state that this is my original work and that I license the work to the project (Apache Spark) under the project's open source license.
      
      Mentioning dbtsai, viirya and brkyvz whom I can see have worked/authored on these parts before.
      
      Author: Bjarne Fruergaard <bwahlgreen@gmail.com>
      
      Closes #15296 from bwahlgreen/bugfix-spark-17721.
      29396e7d
    • Dongjoon Hyun's avatar
      [SPARK-17612][SQL] Support `DESCRIBE table PARTITION` SQL syntax · 4ecc648a
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      
      This PR implements `DESCRIBE table PARTITION` SQL Syntax again. It was supported until Spark 1.6.2, but was dropped since 2.0.0.
      
      **Spark 1.6.2**
      ```scala
      scala> sql("CREATE TABLE partitioned_table (a STRING, b INT) PARTITIONED BY (c STRING, d STRING)")
      res1: org.apache.spark.sql.DataFrame = [result: string]
      
      scala> sql("ALTER TABLE partitioned_table ADD PARTITION (c='Us', d=1)")
      res2: org.apache.spark.sql.DataFrame = [result: string]
      
      scala> sql("DESC partitioned_table PARTITION (c='Us', d=1)").show(false)
      +----------------------------------------------------------------+
      |result                                                          |
      +----------------------------------------------------------------+
      |a                      string                                   |
      |b                      int                                      |
      |c                      string                                   |
      |d                      string                                   |
      |                                                                |
      |# Partition Information                                         |
      |# col_name             data_type               comment          |
      |                                                                |
      |c                      string                                   |
      |d                      string                                   |
      +----------------------------------------------------------------+
      ```
      
      **Spark 2.0**
      - **Before**
      ```scala
      scala> sql("CREATE TABLE partitioned_table (a STRING, b INT) PARTITIONED BY (c STRING, d STRING)")
      res0: org.apache.spark.sql.DataFrame = []
      
      scala> sql("ALTER TABLE partitioned_table ADD PARTITION (c='Us', d=1)")
      res1: org.apache.spark.sql.DataFrame = []
      
      scala> sql("DESC partitioned_table PARTITION (c='Us', d=1)").show(false)
      org.apache.spark.sql.catalyst.parser.ParseException:
      Unsupported SQL statement
      ```
      
      - **After**
      ```scala
      scala> sql("CREATE TABLE partitioned_table (a STRING, b INT) PARTITIONED BY (c STRING, d STRING)")
      res0: org.apache.spark.sql.DataFrame = []
      
      scala> sql("ALTER TABLE partitioned_table ADD PARTITION (c='Us', d=1)")
      res1: org.apache.spark.sql.DataFrame = []
      
      scala> sql("DESC partitioned_table PARTITION (c='Us', d=1)").show(false)
      +-----------------------+---------+-------+
      |col_name               |data_type|comment|
      +-----------------------+---------+-------+
      |a                      |string   |null   |
      |b                      |int      |null   |
      |c                      |string   |null   |
      |d                      |string   |null   |
      |# Partition Information|         |       |
      |# col_name             |data_type|comment|
      |c                      |string   |null   |
      |d                      |string   |null   |
      +-----------------------+---------+-------+
      
      scala> sql("DESC EXTENDED partitioned_table PARTITION (c='Us', d=1)").show(100,false)
      +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+-------+
      |col_name                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |data_type|comment|
      +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+-------+
      |a                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |string   |null   |
      |b                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |int      |null   |
      |c                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |string   |null   |
      |d                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |string   |null   |
      |# Partition Information                                                                                                                                                                                                                                                                                                                                                                                                                                                            |         |       |
      |# col_name                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |data_type|comment|
      |c                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |string   |null   |
      |d                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |string   |null   |
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |         |       |
      |Detailed Partition Information CatalogPartition(
              Partition Values: [Us, 1]
              Storage(Location: file:/Users/dhyun/SPARK-17612-DESC-PARTITION/spark-warehouse/partitioned_table/c=Us/d=1, InputFormat: org.apache.hadoop.mapred.TextInputFormat, OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, Serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Properties: [serialization.format=1])
              Partition Parameters:{transient_lastDdlTime=1475001066})|         |       |
      +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+-------+
      
      scala> sql("DESC FORMATTED partitioned_table PARTITION (c='Us', d=1)").show(100,false)
      +--------------------------------+---------------------------------------------------------------------------------------+-------+
      |col_name                        |data_type                                                                              |comment|
      +--------------------------------+---------------------------------------------------------------------------------------+-------+
      |a                               |string                                                                                 |null   |
      |b                               |int                                                                                    |null   |
      |c                               |string                                                                                 |null   |
      |d                               |string                                                                                 |null   |
      |# Partition Information         |                                                                                       |       |
      |# col_name                      |data_type                                                                              |comment|
      |c                               |string                                                                                 |null   |
      |d                               |string                                                                                 |null   |
      |                                |                                                                                       |       |
      |# Detailed Partition Information|                                                                                       |       |
      |Partition Value:                |[Us, 1]                                                                                |       |
      |Database:                       |default                                                                                |       |
      |Table:                          |partitioned_table                                                                      |       |
      |Location:                       |file:/Users/dhyun/SPARK-17612-DESC-PARTITION/spark-warehouse/partitioned_table/c=Us/d=1|       |
      |Partition Parameters:           |                                                                                       |       |
      |  transient_lastDdlTime         |1475001066                                                                             |       |
      |                                |                                                                                       |       |
      |# Storage Information           |                                                                                       |       |
      |SerDe Library:                  |org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe                                     |       |
      |InputFormat:                    |org.apache.hadoop.mapred.TextInputFormat                                               |       |
      |OutputFormat:                   |org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat                             |       |
      |Compressed:                     |No                                                                                     |       |
      |Storage Desc Parameters:        |                                                                                       |       |
      |  serialization.format          |1                                                                                      |       |
      +--------------------------------+---------------------------------------------------------------------------------------+-------+
      ```
      
      ## How was this patch tested?
      
      Pass the Jenkins tests with a new testcase.
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #15168 from dongjoon-hyun/SPARK-17612.
      4ecc648a
    • Liang-Chi Hsieh's avatar
      [SPARK-17653][SQL] Remove unnecessary distincts in multiple unions · 566d7f28
      Liang-Chi Hsieh authored
      ## What changes were proposed in this pull request?
      
      Currently for `Union [Distinct]`, a `Distinct` operator is necessary to be on the top of `Union`. Once there are adjacent `Union [Distinct]`,  there will be multiple `Distinct` in the query plan.
      
      E.g.,
      
      For a query like: select 1 a union select 2 b union select 3 c
      
      Before this patch, its physical plan looks like:
      
          *HashAggregate(keys=[a#13], functions=[])
          +- Exchange hashpartitioning(a#13, 200)
             +- *HashAggregate(keys=[a#13], functions=[])
                +- Union
                   :- *HashAggregate(keys=[a#13], functions=[])
                   :  +- Exchange hashpartitioning(a#13, 200)
                   :     +- *HashAggregate(keys=[a#13], functions=[])
                   :        +- Union
                   :           :- *Project [1 AS a#13]
                   :           :  +- Scan OneRowRelation[]
                   :           +- *Project [2 AS b#14]
                   :              +- Scan OneRowRelation[]
                   +- *Project [3 AS c#15]
                      +- Scan OneRowRelation[]
      
      Only the top distinct should be necessary.
      
      After this patch, the physical plan looks like:
      
          *HashAggregate(keys=[a#221], functions=[], output=[a#221])
          +- Exchange hashpartitioning(a#221, 5)
             +- *HashAggregate(keys=[a#221], functions=[], output=[a#221])
                +- Union
                   :- *Project [1 AS a#221]
                   :  +- Scan OneRowRelation[]
                   :- *Project [2 AS b#222]
                   :  +- Scan OneRowRelation[]
                   +- *Project [3 AS c#223]
                      +- Scan OneRowRelation[]
      
      ## How was this patch tested?
      
      Jenkins tests.
      
      Author: Liang-Chi Hsieh <viirya@gmail.com>
      
      Closes #15238 from viirya/remove-extra-distinct-union.
      566d7f28
    • Michael Armbrust's avatar
      [SPARK-17699] Support for parsing JSON string columns · fe33121a
      Michael Armbrust authored
      Spark SQL has great support for reading text files that contain JSON data.  However, in many cases the JSON data is just one column amongst others.  This is particularly true when reading from sources such as Kafka.  This PR adds a new functions `from_json` that converts a string column into a nested `StructType` with a user specified schema.
      
      Example usage:
      ```scala
      val df = Seq("""{"a": 1}""").toDS()
      val schema = new StructType().add("a", IntegerType)
      
      df.select(from_json($"value", schema) as 'json) // => [json: <a: int>]
      ```
      
      This PR adds support for java, scala and python.  I leveraged our existing JSON parsing support by moving it into catalyst (so that we could define expressions using it).  I left SQL out for now, because I'm not sure how users would specify a schema.
      
      Author: Michael Armbrust <michael@databricks.com>
      
      Closes #15274 from marmbrus/jsonParser.
      fe33121a
    • Brian Cho's avatar
      [SPARK-17715][SCHEDULER] Make task launch logs DEBUG · 027dea8f
      Brian Cho authored
      ## What changes were proposed in this pull request?
      
      Ramp down the task launch logs from INFO to DEBUG. Task launches can happen orders of magnitude more than executor registration so it makes the logs easier to handle if they are different log levels. For larger jobs, there can be 100,000s of task launches which makes the driver log huge.
      
      ## How was this patch tested?
      
      No tests, as this is a trivial change.
      
      Author: Brian Cho <bcho@fb.com>
      
      Closes #15290 from dafrista/ramp-down-task-logging.
      027dea8f
    • Gang Wu's avatar
      [SPARK-17672] Spark 2.0 history server web Ui takes too long for a single application · cb87b3ce
      Gang Wu authored
      Added a new API getApplicationInfo(appId: String) in class ApplicationHistoryProvider and class SparkUI to get app info. In this change, FsHistoryProvider can directly fetch one app info in O(1) time complexity compared to O(n) before the change which used an Iterator.find() interface.
      
      Both ApplicationCache and OneApplicationResource classes adopt this new api.
      
       manual tests
      
      Author: Gang Wu <wgtmac@uber.com>
      
      Closes #15247 from wgtmac/SPARK-17671.
      cb87b3ce
    • Imran Rashid's avatar
      [SPARK-17648][CORE] TaskScheduler really needs offers to be an IndexedSeq · 7f779e74
      Imran Rashid authored
      ## What changes were proposed in this pull request?
      
      The Seq[WorkerOffer] is accessed by index, so it really should be an
      IndexedSeq, otherwise an O(n) operation becomes O(n^2).  In practice
      this hasn't been an issue b/c where these offers are generated, the call
      to `.toSeq` just happens to create an IndexedSeq anyway.I got bitten by
      this in performance tests I was doing, and its better for the types to be
      more precise so eg. a change in Scala doesn't destroy performance.
      
      ## How was this patch tested?
      
      Unit tests via jenkins.
      
      Author: Imran Rashid <irashid@cloudera.com>
      
      Closes #15221 from squito/SPARK-17648.
      7f779e74
    • José Hiram Soltren's avatar
      [DOCS] Reorganize explanation of Accumulators and Broadcast Variables · 95820049
      José Hiram Soltren authored
      ## What changes were proposed in this pull request?
      
      The discussion of the interaction of Accumulators and Broadcast Variables should logically follow the discussion on Checkpointing. As currently written, this section discusses Checkpointing before it is formally introduced. To remedy this:
      
       - Rename this section to "Accumulators, Broadcast Variables, and Checkpoints", and
       - Move this section after "Checkpointing".
      
      ## How was this patch tested?
      
      Testing: ran
      
      $ SKIP_API=1 jekyll build
      
      , and verified changes in a Web browser pointed at docs/_site/index.html.
      
      Author: José Hiram Soltren <jose@cloudera.com>
      
      Closes #15281 from jsoltren/doc-changes.
      95820049
    • Takeshi YAMAMURO's avatar
      [MINOR][DOCS] Fix th doc. of spark-streaming with kinesis · b2e9731c
      Takeshi YAMAMURO authored
      ## What changes were proposed in this pull request?
      This pr is just to fix the document of `spark-kinesis-integration`.
      Since `SPARK-17418` prevented all the kinesis stuffs (including kinesis example code)
      from publishing,  `bin/run-example streaming.KinesisWordCountASL` and `bin/run-example streaming.JavaKinesisWordCountASL` does not work.
      Instead, it fetches the kinesis jar from the Spark Package.
      
      Author: Takeshi YAMAMURO <linguin.m.s@gmail.com>
      
      Closes #15260 from maropu/DocFixKinesis.
      Unverified
      b2e9731c
    • Sean Owen's avatar
      [SPARK-17614][SQL] sparkSession.read() .jdbc(***) use the sql syntax "where... · b35b0dbb
      Sean Owen authored
      [SPARK-17614][SQL] sparkSession.read() .jdbc(***) use the sql syntax "where 1=0" that Cassandra does not support
      
      ## What changes were proposed in this pull request?
      
      Use dialect's table-exists query rather than hard-coded WHERE 1=0 query
      
      ## How was this patch tested?
      
      Existing tests.
      
      Author: Sean Owen <sowen@cloudera.com>
      
      Closes #15196 from srowen/SPARK-17614.
      Unverified
      b35b0dbb
    • Yanbo Liang's avatar
      [SPARK-17704][ML][MLLIB] ChiSqSelector performance improvement. · f7082ac1
      Yanbo Liang authored
      ## What changes were proposed in this pull request?
      Several performance improvement for ```ChiSqSelector```:
      1, Keep ```selectedFeatures``` ordered ascendent.
      ```ChiSqSelectorModel.transform``` need ```selectedFeatures``` ordered to make prediction. We should sort it when training model rather than making prediction, since users usually train model once and use the model to do prediction multiple times.
      2, When training ```fpr``` type ```ChiSqSelectorModel```, it's not necessary to sort the ChiSq test result by statistic.
      
      ## How was this patch tested?
      Existing unit tests.
      
      Author: Yanbo Liang <ybliang8@gmail.com>
      
      Closes #15277 from yanboliang/spark-17704.
      f7082ac1
    • Yanbo Liang's avatar
      [SPARK-16356][FOLLOW-UP][ML] Enforce ML test of exception for local/distributed Dataset. · a19a1bb5
      Yanbo Liang authored
      ## What changes were proposed in this pull request?
      #14035 added ```testImplicits``` to ML unit tests and promoted ```toDF()```, but left one minor issue at ```VectorIndexerSuite```. If we create the DataFrame by ```Seq(...).toDF()```, it will throw different error/exception compared with ```sc.parallelize(Seq(...)).toDF()``` for one of the test cases.
      After in-depth study, I found it was caused by different behavior of local and distributed Dataset if the UDF failed at ```assert```. If the data is local Dataset, it throws ```AssertionError``` directly; If the data is distributed Dataset, it throws ```SparkException``` which is the wrapper of ```AssertionError```. I think we should enforce this test to cover both case.
      
      ## How was this patch tested?
      Unit test.
      
      Author: Yanbo Liang <ybliang8@gmail.com>
      
      Closes #15261 from yanboliang/spark-16356.
      a19a1bb5
  2. Sep 28, 2016
  3. Sep 27, 2016
    • hyukjinkwon's avatar
      [SPARK-17499][SPARKR][FOLLOWUP] Check null first for layers in spark.mlp to... · 4a833956
      hyukjinkwon authored
      [SPARK-17499][SPARKR][FOLLOWUP] Check null first for layers in spark.mlp to avoid warnings in test results
      
      ## What changes were proposed in this pull request?
      
      Some tests in `test_mllib.r` are as below:
      
      ```r
      expect_error(spark.mlp(df, layers = NULL), "layers must be a integer vector with length > 1.")
      expect_error(spark.mlp(df, layers = c()), "layers must be a integer vector with length > 1.")
      ```
      
      The problem is, `is.na` is internally called via `na.omit` in `spark.mlp` which causes warnings as below:
      
      ```
      Warnings -----------------------------------------------------------------------
      1. spark.mlp (test_mllib.R#400) - is.na() applied to non-(list or vector) of type 'NULL'
      
      2. spark.mlp (test_mllib.R#401) - is.na() applied to non-(list or vector) of type 'NULL'
      ```
      
      ## How was this patch tested?
      
      Manually tested. Also, Jenkins tests and AppVeyor.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #15232 from HyukjinKwon/remove-warnnings.
      4a833956
    • Josh Rosen's avatar
      [SPARK-17666] Ensure that RecordReaders are closed by data source file scans · b03b4adf
      Josh Rosen authored
      ## What changes were proposed in this pull request?
      
      This patch addresses a potential cause of resource leaks in data source file scans. As reported in [SPARK-17666](https://issues.apache.org/jira/browse/SPARK-17666), tasks which do not fully-consume their input may cause file handles / network connections (e.g. S3 connections) to be leaked. Spark's `NewHadoopRDD` uses a TaskContext callback to [close its record readers](https://github.com/apache/spark/blame/master/core/src/main/scala/org/apache/spark/rdd/NewHadoopRDD.scala#L208), but the new data source file scans will only close record readers once their iterators are fully-consumed.
      
      This patch modifies `RecordReaderIterator` and `HadoopFileLinesReader` to add `close()` methods and modifies all six implementations of `FileFormat.buildReader()` to register TaskContext task completion callbacks to guarantee that cleanup is eventually performed.
      
      ## How was this patch tested?
      
      Tested manually for now.
      
      Author: Josh Rosen <joshrosen@databricks.com>
      
      Closes #15245 from JoshRosen/SPARK-17666-close-recordreader.
      b03b4adf
    • Liang-Chi Hsieh's avatar
      [SPARK-17056][CORE] Fix a wrong assert regarding unroll memory in MemoryStore · e7bce9e1
      Liang-Chi Hsieh authored
      ## What changes were proposed in this pull request?
      
      There is an assert in MemoryStore's putIteratorAsValues method which is used to check if unroll memory is not released too much. This assert looks wrong.
      
      ## How was this patch tested?
      
      Jenkins tests.
      
      Author: Liang-Chi Hsieh <simonh@tw.ibm.com>
      
      Closes #14642 from viirya/fix-unroll-memory.
      e7bce9e1
    • Josh Rosen's avatar
      [SPARK-17618] Guard against invalid comparisons between UnsafeRow and other formats · 2f84a686
      Josh Rosen authored
      This patch ports changes from #15185 to Spark 2.x. In that patch, a  correctness bug in Spark 1.6.x which was caused by an invalid `equals()` comparison between an `UnsafeRow` and another row of a different format. Spark 2.x is not affected by that specific correctness bug but it can still reap the error-prevention benefits of that patch's changes, which modify  ``UnsafeRow.equals()` to throw an IllegalArgumentException if it is called with an object that is not an `UnsafeRow`.
      
      Author: Josh Rosen <joshrosen@databricks.com>
      
      Closes #15265 from JoshRosen/SPARK-17618-master.
      2f84a686
    • Reynold Xin's avatar
      [SPARK-17677][SQL] Break WindowExec.scala into multiple files · 67c73052
      Reynold Xin authored
      ## What changes were proposed in this pull request?
      As of Spark 2.0, all the window function execution code are in WindowExec.scala. This file is pretty large (over 1k loc) and has a lot of different abstractions in them. This patch creates a new package sql.execution.window, moves WindowExec.scala in it, and breaks WindowExec.scala into multiple, more maintainable pieces:
      
      - AggregateProcessor.scala
      - BoundOrdering.scala
      - RowBuffer.scala
      - WindowExec
      - WindowFunctionFrame.scala
      
      ## How was this patch tested?
      This patch mostly moves code around, and should not change any existing test coverage.
      
      Author: Reynold Xin <rxin@databricks.com>
      
      Closes #15252 from rxin/SPARK-17677.
      67c73052
    • gatorsmile's avatar
      [SPARK-17660][SQL] DESC FORMATTED for VIEW Lacks View Definition · 2ab24a7b
      gatorsmile authored
      ### What changes were proposed in this pull request?
      Before this PR, `DESC FORMATTED` does not have a section for the view definition. We should add it for permanent views, like what Hive does.
      
      ```
      +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------+-------+
      |col_name                    |data_type                                                                                                                            |comment|
      +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------+-------+
      |a                           |int                                                                                                                                  |null   |
      |                            |                                                                                                                                     |       |
      |# Detailed Table Information|                                                                                                                                     |       |
      |Database:                   |default                                                                                                                              |       |
      |Owner:                      |xiaoli                                                                                                                               |       |
      |Create Time:                |Sat Sep 24 21:46:19 PDT 2016                                                                                                         |       |
      |Last Access Time:           |Wed Dec 31 16:00:00 PST 1969                                                                                                         |       |
      |Location:                   |                                                                                                                                     |       |
      |Table Type:                 |VIEW                                                                                                                                 |       |
      |Table Parameters:           |                                                                                                                                     |       |
      |  transient_lastDdlTime     |1474778779                                                                                                                           |       |
      |                            |                                                                                                                                     |       |
      |# Storage Information       |                                                                                                                                     |       |
      |SerDe Library:              |org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe                                                                                   |       |
      |InputFormat:                |org.apache.hadoop.mapred.SequenceFileInputFormat                                                                                     |       |
      |OutputFormat:               |org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat                                                                            |       |
      |Compressed:                 |No                                                                                                                                   |       |
      |Storage Desc Parameters:    |                                                                                                                                     |       |
      |  serialization.format      |1                                                                                                                                    |       |
      |                            |                                                                                                                                     |       |
      |# View Information          |                                                                                                                                     |       |
      |View Original Text:         |SELECT * FROM tbl                                                                                                                    |       |
      |View Expanded Text:         |SELECT `gen_attr_0` AS `a` FROM (SELECT `gen_attr_0` FROM (SELECT `a` AS `gen_attr_0` FROM `default`.`tbl`) AS gen_subquery_0) AS tbl|       |
      +----------------------------+-------------------------------------------------------------------------------------------------------------------------------------+-------+
      ```
      
      ### How was this patch tested?
      Added a test case
      
      Author: gatorsmile <gatorsmile@gmail.com>
      
      Closes #15234 from gatorsmile/descFormattedView.
      2ab24a7b
    • Reynold Xin's avatar
      [SPARK-17682][SQL] Mark children as final for unary, binary, leaf expressions and plan nodes · 120723f9
      Reynold Xin authored
      ## What changes were proposed in this pull request?
      This patch marks the children method as final in unary, binary, and leaf expressions and plan nodes (both logical plan and physical plan), as brought up in http://apache-spark-developers-list.1001551.n3.nabble.com/Should-LeafExpression-have-children-final-override-like-Nondeterministic-td19104.html
      
      ## How was this patch tested?
      This is a simple modifier change and has no impact on test coverage.
      
      Author: Reynold Xin <rxin@databricks.com>
      
      Closes #15256 from rxin/SPARK-17682.
      120723f9
    • hyukjinkwon's avatar
      [SPARK-16516][SQL] Support for pushing down filters for decimal and timestamp types in ORC · 2cac3b2d
      hyukjinkwon authored
      ## What changes were proposed in this pull request?
      
      It seems ORC supports all the types in  ([`PredicateLeaf.Type`](https://github.com/apache/hive/blob/e085b7e9bd059d91aaf013df0db4d71dca90ec6f/storage-api/src/java/org/apache/hadoop/hive/ql/io/sarg/PredicateLeaf.java#L50-L56)) which includes timestamp type and decimal type.
      
      In more details, the types listed in [`SearchArgumentImpl.boxLiteral()`](https://github.com/apache/hive/blob/branch-1.2/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java#L1068-L1093) can be used as a filter value.
      
      FYI, inital `case` caluse for supported types was introduced in https://github.com/apache/spark/commit/65d71bd9fbfe6fe1b741c80fed72d6ae3d22b028 and this was not changed overtime. At that time, Hive version was, 0.13 which supports only some types for filter-push down (See [SearchArgumentImpl.java#L945-L965](https://github.com/apache/hive/blob/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java#L945-L965) at 0.13).
      
      However, the version was upgraded into 1.2.x and now it supports more types (See [SearchArgumentImpl.java#L1068-L1093](https://github.com/apache/hive/blob/branch-1.2/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java#L1068-L1093) at 1.2.0)
      
      ## How was this patch tested?
      
      Unit tests in `OrcFilterSuite` and `OrcQuerySuite`
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #14172 from HyukjinKwon/SPARK-16516.
      2cac3b2d
    • hyukjinkwon's avatar
      [SPARK-16777][SQL] Do not use deprecated listType API in ParquetSchemaConverter · 5de1737b
      hyukjinkwon authored
      ## What changes were proposed in this pull request?
      
      This PR removes build waning as below.
      
      ```scala
      [WARNING] .../spark/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaConverter.scala:448: method listType in object ConversionPatterns is deprecated: see corresponding Javadoc for more information.
      [WARNING]         ConversionPatterns.listType(
      [WARNING]                            ^
      [WARNING] .../spark/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaConverter.scala:464: method listType in object ConversionPatterns is deprecated: see corresponding Javadoc for more information.
      [WARNING]         ConversionPatterns.listType(
      [WARNING]                            ^
      ```
      
      This should not use `listOfElements` (recommended to be replaced from `listType`) instead because the new method checks if the name of elements in Parquet's `LIST` is `element` in Parquet schema and throws an exception if not. However, It seems Spark prior to 1.4.x writes `ArrayType` with Parquet's `LIST` but with `array` as its element name.
      
      Therefore, this PR avoids to use both `listOfElements` and `listType` but just use the existing schema builder to construct the same `GroupType`.
      
      ## How was this patch tested?
      
      Existing tests should cover this.
      
      Author: hyukjinkwon <gurwls223@gmail.com>
      
      Closes #14399 from HyukjinKwon/SPARK-16777.
      5de1737b
    • Weiqing Yang's avatar
      [SPARK-16757] Set up Spark caller context to HDFS and YARN · 6a68c5d7
      Weiqing Yang authored
      ## What changes were proposed in this pull request?
      
      1. Pass `jobId` to Task.
      2. Invoke Hadoop APIs.
          * A new function `setCallerContext` is added in `Utils`. `setCallerContext` function invokes APIs of   `org.apache.hadoop.ipc.CallerContext` to set up spark caller contexts, which will be written into `hdfs-audit.log` and Yarn RM audit log.
          * For HDFS: Spark sets up its caller context by invoking`org.apache.hadoop.ipc.CallerContext` in `Task` and Yarn `Client` and `ApplicationMaster`.
          * For Yarn: Spark sets up its caller context by invoking `org.apache.hadoop.ipc.CallerContext` in Yarn `Client`.
      
      ## How was this patch tested?
      Manual Tests against some Spark applications in Yarn client mode and Yarn cluster mode. Need to check if spark caller contexts are written into HDFS hdfs-audit.log and Yarn RM audit log successfully.
      
      For example, run SparkKmeans in Yarn client mode:
      ```
      ./bin/spark-submit --verbose --executor-cores 3 --num-executors 1 --master yarn --deploy-mode client --class org.apache.spark.examples.SparkKMeans examples/target/original-spark-examples_2.11-2.1.0-SNAPSHOT.jar hdfs://localhost:9000/lr_big.txt 2 5
      ```
      
      **Before**:
      There will be no Spark caller context in records of `hdfs-audit.log` and Yarn RM audit log.
      
      **After**:
      Spark caller contexts will be written in records of `hdfs-audit.log` and Yarn RM audit log.
      
      These are records in `hdfs-audit.log`:
      ```
      2016-09-20 11:54:24,116 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_CLIENT_AppId_application_1474394339641_0005
      2016-09-20 11:54:28,164 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0005_JobId_0_StageId_0_AttemptId_0_TaskId_2_AttemptNum_0
      2016-09-20 11:54:28,164 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0005_JobId_0_StageId_0_AttemptId_0_TaskId_1_AttemptNum_0
      2016-09-20 11:54:28,164 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0005_JobId_0_StageId_0_AttemptId_0_TaskId_0_AttemptNum_0
      ```
      ```
      2016-09-20 11:59:33,868 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=mkdirs	src=/private/tmp/hadoop-wyang/nm-local-dir/usercache/wyang/appcache/application_1474394339641_0006/container_1474394339641_0006_01_000001/spark-warehouse	dst=null	perm=wyang:supergroup:rwxr-xr-x	proto=rpc	callerContext=SPARK_APPLICATION_MASTER_AppId_application_1474394339641_0006_AttemptId_1
      2016-09-20 11:59:37,214 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0006_AttemptId_1_JobId_0_StageId_0_AttemptId_0_TaskId_1_AttemptNum_0
      2016-09-20 11:59:37,215 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0006_AttemptId_1_JobId_0_StageId_0_AttemptId_0_TaskId_2_AttemptNum_0
      2016-09-20 11:59:37,215 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0006_AttemptId_1_JobId_0_StageId_0_AttemptId_0_TaskId_0_AttemptNum_0
      2016-09-20 11:59:42,391 INFO FSNamesystem.audit: allowed=true	ugi=wyang (auth:SIMPLE)	ip=/127.0.0.1	cmd=open	src=/lr_big.txt	dst=null	perm=null	proto=rpc	callerContext=SPARK_TASK_AppId_application_1474394339641_0006_AttemptId_1_JobId_0_StageId_0_AttemptId_0_TaskId_3_AttemptNum_0
      ```
      This is a record in Yarn RM log:
      ```
      2016-09-20 11:59:24,050 INFO org.apache.hadoop.yarn.server.resourcemanager.RMAuditLogger: USER=wyang	IP=127.0.0.1	OPERATION=Submit Application Request	TARGET=ClientRMService	RESULT=SUCCESS	APPID=application_1474394339641_0006	CALLERCONTEXT=SPARK_CLIENT_AppId_application_1474394339641_0006
      ```
      
      Author: Weiqing Yang <yangweiqing001@gmail.com>
      
      Closes #14659 from Sherry302/callercontextSubmit.
      6a68c5d7
    • WeichenXu's avatar
      [SPARK-17138][ML][MLIB] Add Python API for multinomial logistic regression · 7f16affa
      WeichenXu authored
      ## What changes were proposed in this pull request?
      
      Add Python API for multinomial logistic regression.
      
      - add `family` param in python api.
      - expose `coefficientMatrix` and `interceptVector` for `LogisticRegressionModel`
      - add python-side testcase for multinomial logistic regression
      - update python doc.
      
      ## How was this patch tested?
      
      existing and added doc tests.
      
      Author: WeichenXu <WeichenXu123@outlook.com>
      
      Closes #14852 from WeichenXu123/add_MLOR_python.
      7f16affa
    • Kazuaki Ishizaki's avatar
      [SPARK-15962][SQL] Introduce implementation with a dense format for UnsafeArrayData · 85b0a157
      Kazuaki Ishizaki authored
      ## What changes were proposed in this pull request?
      
      This PR introduces more compact representation for ```UnsafeArrayData```.
      
      ```UnsafeArrayData``` needs to accept ```null``` value in each entry of an array. In the current version, it has three parts
      ```
      [numElements] [offsets] [values]
      ```
      `Offsets` has the number of `numElements`, and represents `null` if its value is negative. It may increase memory footprint, and introduces an indirection for accessing each of `values`.
      
      This PR uses bitvectors to represent nullability for each element like `UnsafeRow`, and eliminates an indirection for accessing each element. The new ```UnsafeArrayData``` has four parts.
      ```
      [numElements][null bits][values or offset&length][variable length portion]
      ```
      In the `null bits` region, we store 1 bit per element, represents whether an element is null. Its total size is ceil(numElements / 8) bytes, and it is aligned to 8-byte boundaries.
      In the `values or offset&length` region, we store the content of elements. For fields that hold fixed-length primitive types, such as long, double, or int, we store the value directly in the field. For fields with non-primitive or variable-length values, we store a relative offset (w.r.t. the base address of the array) that points to the beginning of the variable-length field and length (they are combined into a long). Each is word-aligned. For `variable length portion`, each is aligned to 8-byte boundaries.
      
      The new format can reduce memory footprint and improve performance of accessing each element. An example of memory foot comparison:
      1024x1024 elements integer array
      Size of ```baseObject``` for ```UnsafeArrayData```: 8 + 1024x1024 + 1024x1024 = 2M bytes
      Size of ```baseObject``` for ```UnsafeArrayData```: 8 + 1024x1024/8 + 1024x1024 = 1.25M bytes
      
      In summary, we got 1.0-2.6x performance improvements over the code before applying this PR.
      Here are performance results of [benchmark programs](https://github.com/kiszk/spark/blob/04d2e4b6dbdc4eff43ce18b3c9b776e0129257c7/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/UnsafeArrayDataBenchmark.scala):
      
      **Read UnsafeArrayData**: 1.7x and 1.6x performance improvements over the code before applying this PR
      ````
      OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.4.11-200.fc22.x86_64
      Intel Xeon E3-12xx v2 (Ivy Bridge)
      
      Without SPARK-15962
      Read UnsafeArrayData:                    Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            430 /  436        390.0           2.6       1.0X
      Double                                         456 /  485        367.8           2.7       0.9X
      
      With SPARK-15962
      Read UnsafeArrayData:                    Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            252 /  260        666.1           1.5       1.0X
      Double                                         281 /  292        597.7           1.7       0.9X
      ````
      **Write UnsafeArrayData**: 1.0x and 1.1x performance improvements over the code before applying this PR
      ````
      OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.0.4-301.fc22.x86_64
      Intel Xeon E3-12xx v2 (Ivy Bridge)
      
      Without SPARK-15962
      Write UnsafeArrayData:                   Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            203 /  273        103.4           9.7       1.0X
      Double                                         239 /  356         87.9          11.4       0.8X
      
      With SPARK-15962
      Write UnsafeArrayData:                   Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            196 /  249        107.0           9.3       1.0X
      Double                                         227 /  367         92.3          10.8       0.9X
      ````
      
      **Get primitive array from UnsafeArrayData**: 2.6x and 1.6x performance improvements over the code before applying this PR
      ````
      OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.0.4-301.fc22.x86_64
      Intel Xeon E3-12xx v2 (Ivy Bridge)
      
      Without SPARK-15962
      Get primitive array from UnsafeArrayData: Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            207 /  217        304.2           3.3       1.0X
      Double                                         257 /  363        245.2           4.1       0.8X
      
      With SPARK-15962
      Get primitive array from UnsafeArrayData: Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            151 /  198        415.8           2.4       1.0X
      Double                                         214 /  394        293.6           3.4       0.7X
      ````
      
      **Create UnsafeArrayData from primitive array**: 1.7x and 2.1x performance improvements over the code before applying this PR
      ````
      OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.0.4-301.fc22.x86_64
      Intel Xeon E3-12xx v2 (Ivy Bridge)
      
      Without SPARK-15962
      Create UnsafeArrayData from primitive array: Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            340 /  385        185.1           5.4       1.0X
      Double                                         479 /  705        131.3           7.6       0.7X
      
      With SPARK-15962
      Create UnsafeArrayData from primitive array: Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      Int                                            206 /  211        306.0           3.3       1.0X
      Double                                         232 /  406        271.6           3.7       0.9X
      ````
      
      1.7x and 1.4x performance improvements in [```UDTSerializationBenchmark```](https://github.com/apache/spark/blob/master/mllib/src/test/scala/org/apache/spark/mllib/linalg/UDTSerializationBenchmark.scala)  over the code before applying this PR
      ````
      OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.4.11-200.fc22.x86_64
      Intel Xeon E3-12xx v2 (Ivy Bridge)
      
      Without SPARK-15962
      VectorUDT de/serialization:              Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      serialize                                      442 /  533          0.0      441927.1       1.0X
      deserialize                                    217 /  274          0.0      217087.6       2.0X
      
      With SPARK-15962
      VectorUDT de/serialization:              Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
      ------------------------------------------------------------------------------------------------
      serialize                                      265 /  318          0.0      265138.5       1.0X
      deserialize                                    155 /  197          0.0      154611.4       1.7X
      ````
      
      ## How was this patch tested?
      
      Added unit tests into ```UnsafeArraySuite```
      
      Author: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
      
      Closes #13680 from kiszk/SPARK-15962.
      85b0a157
    • Ding Fei's avatar
      Fix two comments since Actor is not used anymore. · 6ee28423
      Ding Fei authored
      ## What changes were proposed in this pull request?
      
      Fix two comments since Actor is not used anymore.
      
      Author: Ding Fei <danis@danix>
      
      Closes #15251 from danix800/comment-fixing.
      6ee28423
  4. Sep 26, 2016
    • Yanbo Liang's avatar
      [SPARK-17577][FOLLOW-UP][SPARKR] SparkR spark.addFile supports adding directory recursively · 93c743f1
      Yanbo Liang authored
      ## What changes were proposed in this pull request?
      #15140 exposed ```JavaSparkContext.addFile(path: String, recursive: Boolean)``` to Python/R, then we can update SparkR ```spark.addFile``` to support adding directory recursively.
      
      ## How was this patch tested?
      Added unit test.
      
      Author: Yanbo Liang <ybliang8@gmail.com>
      
      Closes #15216 from yanboliang/spark-17577-2.
      93c743f1
    • Andrew Mills's avatar
      [Docs] Update spark-standalone.md to fix link · 00be16df
      Andrew Mills authored
      Corrected a link to the configuration.html page, it was pointing to a page that does not exist (configurations.html).
      
      Documentation change, verified in preview.
      
      Author: Andrew Mills <ammills01@users.noreply.github.com>
      
      Closes #15244 from ammills01/master.
      00be16df
    • Sameer Agarwal's avatar
      [SPARK-17652] Fix confusing exception message while reserving capacity · 7c7586ae
      Sameer Agarwal authored
      ## What changes were proposed in this pull request?
      
      This minor patch fixes a confusing exception message while reserving additional capacity in the vectorized parquet reader.
      
      ## How was this patch tested?
      
      Exisiting Unit Tests
      
      Author: Sameer Agarwal <sameerag@cs.berkeley.edu>
      
      Closes #15225 from sameeragarwal/error-msg.
      7c7586ae
    • Liang-Chi Hsieh's avatar
      [SPARK-17153][SQL] Should read partition data when reading new files in filestream without globbing · 8135e0e5
      Liang-Chi Hsieh authored
      ## What changes were proposed in this pull request?
      
      When reading file stream with non-globbing path, the results return data with all `null`s for the
      partitioned columns. E.g.,
      
          case class A(id: Int, value: Int)
          val data = spark.createDataset(Seq(
            A(1, 1),
            A(2, 2),
            A(2, 3))
          )
          val url = "/tmp/test"
          data.write.partitionBy("id").parquet(url)
          spark.read.parquet(url).show
      
          +-----+---+
          |value| id|
          +-----+---+
          |    2|  2|
          |    3|  2|
          |    1|  1|
          +-----+---+
      
          val s = spark.readStream.schema(spark.read.load(url).schema).parquet(url)
          s.writeStream.queryName("test").format("memory").start()
      
          sql("SELECT * FROM test").show
      
          +-----+----+
          |value|  id|
          +-----+----+
          |    2|null|
          |    3|null|
          |    1|null|
          +-----+----+
      
      ## How was this patch tested?
      
      Jenkins tests.
      
      Author: Liang-Chi Hsieh <simonh@tw.ibm.com>
      Author: Liang-Chi Hsieh <viirya@gmail.com>
      
      Closes #14803 from viirya/filestreamsource-option.
      8135e0e5
Loading