Skip to content
Snippets Groups Projects
  1. Feb 13, 2017
    • Liwei Lin's avatar
      [SPARK-19564][SPARK-19559][SS][KAFKA] KafkaOffsetReader's consumers should not be in the same group · 2bdbc870
      Liwei Lin authored
      ## What changes were proposed in this pull request?
      
      In `KafkaOffsetReader`, when error occurs, we abort the existing consumer and create a new consumer. In our current implementation, the first consumer and the second consumer would be in the same group (which leads to SPARK-19559), **_violating our intention of the two consumers not being in the same group._**
      
      The cause is that, in our current implementation, the first consumer is created before `groupId` and `nextId` are initialized in the constructor. Then even if `groupId` and `nextId` are increased during the creation of that first consumer, `groupId` and `nextId` would still be initialized to default values in the constructor for the second consumer.
      
      We should make sure that `groupId` and `nextId` are initialized before any consumer is created.
      
      ## How was this patch tested?
      
      Ran 100 times of `KafkaSourceSuite`; all passed
      
      Author: Liwei Lin <lwlin7@gmail.com>
      
      Closes #16902 from lw-lin/SPARK-19564-.
      2bdbc870
  2. Feb 12, 2017
    • titicaca's avatar
      [SPARK-19342][SPARKR] bug fixed in collect method for collecting timestamp column · bc0a0e63
      titicaca authored
      ## What changes were proposed in this pull request?
      
      Fix a bug in collect method for collecting timestamp column, the bug can be reproduced as shown in the following codes and outputs:
      
      ```
      library(SparkR)
      sparkR.session(master = "local")
      df <- data.frame(col1 = c(0, 1, 2),
                       col2 = c(as.POSIXct("2017-01-01 00:00:01"), NA, as.POSIXct("2017-01-01 12:00:01")))
      
      sdf1 <- createDataFrame(df)
      print(dtypes(sdf1))
      df1 <- collect(sdf1)
      print(lapply(df1, class))
      
      sdf2 <- filter(sdf1, "col1 > 0")
      print(dtypes(sdf2))
      df2 <- collect(sdf2)
      print(lapply(df2, class))
      ```
      
      As we can see from the printed output, the column type of col2 in df2 is converted to numeric unexpectedly, when NA exists at the top of the column.
      
      This is caused by method `do.call(c, list)`, if we convert a list, i.e. `do.call(c, list(NA, as.POSIXct("2017-01-01 12:00:01"))`, the class of the result is numeric instead of POSIXct.
      
      Therefore, we need to cast the data type of the vector explicitly.
      
      ## How was this patch tested?
      
      The patch can be tested manually with the same code above.
      
      Author: titicaca <fangzhou.yang@hotmail.com>
      
      Closes #16689 from titicaca/sparkr-dev.
      bc0a0e63
    • windpiger's avatar
      [SPARK-19448][SQL] optimize some duplication functions between HiveClientImpl and HiveUtils · 3881f342
      windpiger authored
      ## What changes were proposed in this pull request?
      
      There are some duplicate functions between `HiveClientImpl` and `HiveUtils`, we can merge them to one place. such as: `toHiveTable` 、`toHivePartition`、`fromHivePartition`.
      
      And additional modify is change `MetastoreRelation.attributes` to `MetastoreRelation.dataColKeys`
      https://github.com/apache/spark/blob/master/sql/hive/src/main/scala/org/apache/spark/sql/hive/MetastoreRelation.scala#L234
      
      ## How was this patch tested?
      N/A
      
      Author: windpiger <songjun@outlook.com>
      
      Closes #16787 from windpiger/todoInMetaStoreRelation.
      3881f342
  3. Feb 11, 2017
    • Kay Ousterhout's avatar
      [SPARK-19537] Move pendingPartitions to ShuffleMapStage. · 0fbecc73
      Kay Ousterhout authored
      The pendingPartitions instance variable should be moved to ShuffleMapStage,
      because it is only used by ShuffleMapStages. This change is purely refactoring
      and does not change functionality.
      
      I fixed this in an attempt to clarify some of the discussion around #16620, which I was having trouble reasoning about.  I stole the helpful comment Imran wrote for pendingPartitions and used it here.
      
      cc squito markhamstra jinxing64
      
      Author: Kay Ousterhout <kayousterhout@gmail.com>
      
      Closes #16876 from kayousterhout/SPARK-19537.
      0fbecc73
  4. Feb 10, 2017
    • Herman van Hovell's avatar
      [SPARK-19548][SQL] Support Hive UDFs which return typed Lists/Maps · 226d3884
      Herman van Hovell authored
      ## What changes were proposed in this pull request?
      This PR adds support for Hive UDFs that return fully typed java Lists or Maps, for example `List<String>` or `Map<String, Integer>`.  It is also allowed to nest these structures, for example `Map<String, List<Integer>>`. Raw collections or collections using wildcards are still not supported, and cannot be supported due to the lack of type information.
      
      ## How was this patch tested?
      Modified existing tests in `HiveUDFSuite`, and I have added test cases for raw collection and collection using wildcards.
      
      Author: Herman van Hovell <hvanhovell@databricks.com>
      
      Closes #16886 from hvanhovell/SPARK-19548.
      226d3884
    • Ala Luszczak's avatar
      [SPARK-19549] Allow providing reason for stage/job cancelling · d785217b
      Ala Luszczak authored
      ## What changes were proposed in this pull request?
      
      This change add an optional argument to `SparkContext.cancelStage()` and `SparkContext.cancelJob()` functions, which allows the caller to provide exact reason  for the cancellation.
      
      ## How was this patch tested?
      
      Adds unit test.
      
      Author: Ala Luszczak <ala@databricks.com>
      
      Closes #16887 from ala/cancel.
      d785217b
    • sueann's avatar
      [SPARK-18613][ML] make spark.mllib LDA dependencies in spark.ml LDA private · 3a43ae7c
      sueann authored
      ## What changes were proposed in this pull request?
      spark.ml.*LDAModel classes were exposing spark.mllib LDA models via protected methods. Made them package (clustering) private.
      
      ## How was this patch tested?
      ```
      build/sbt doc  # "millib.clustering" no longer appears in the docs for *LDA* classes
      build/sbt compile  # compiles
      build/sbt
      > mllib/testOnly   # tests pass
      ```
      
      Author: sueann <sueann@databricks.com>
      
      Closes #16860 from sueann/SPARK-18613.
      3a43ae7c
    • Herman van Hovell's avatar
      [SPARK-19459][SQL] Add Hive datatype (char/varchar) to StructField metadata · de8a03e6
      Herman van Hovell authored
      ## What changes were proposed in this pull request?
      Reading from an existing ORC table which contains `char` or `varchar` columns can fail with a `ClassCastException` if the table metadata has been created using Spark. This is caused by the fact that spark internally replaces `char` and `varchar` columns with a `string` column.
      
      This PR fixes this by adding the hive type to the `StructField's` metadata under the `HIVE_TYPE_STRING` key. This is picked up by the `HiveClient` and the ORC reader, see https://github.com/apache/spark/pull/16060 for more details on how the metadata is used.
      
      ## How was this patch tested?
      Added a regression test to `OrcSourceSuite`.
      
      Author: Herman van Hovell <hvanhovell@databricks.com>
      
      Closes #16804 from hvanhovell/SPARK-19459.
      de8a03e6
    • Eren Avsarogullari's avatar
      [SPARK-19466][CORE][SCHEDULER] Improve Fair Scheduler Logging · dadff5f0
      Eren Avsarogullari authored
      Fair Scheduler Logging for the following cases can be useful for the user.
      
      1. If **valid** `spark.scheduler.allocation.file` property is set, user can be informed and aware which scheduler file is processed when `SparkContext` initializes.
      
      2. If **invalid** `spark.scheduler.allocation.file` property is set, currently, the following stacktrace is shown to user. In addition to this, more meaningful message can be shown to user by emphasizing the problem at building level of fair scheduler. Also other potential issues can be covered at this level as **Fair Scheduler can not be built. + exception stacktrace**
      ```
      Exception in thread "main" java.io.FileNotFoundException: INVALID_FILE (No such file or directory)
      	at java.io.FileInputStream.open0(Native Method)
      	at java.io.FileInputStream.open(FileInputStream.java:195)
      	at java.io.FileInputStream.<init>(FileInputStream.java:138)
      	at java.io.FileInputStream.<init>(FileInputStream.java:93)
      	at org.apache.spark.scheduler.FairSchedulableBuilder$$anonfun$buildPools$1.apply(SchedulableBuilder.scala:76)
      	at org.apache.spark.scheduler.FairSchedulableBuilder$$anonfun$buildPools$1.apply(SchedulableBuilder.scala:75)
      ```
      3. If `spark.scheduler.allocation.file` property is not set and **default** fair scheduler file (**fairscheduler.xml**) is found in classpath, it will be loaded but currently, user is not informed for using default file so logging can be useful as **Fair Scheduler file: fairscheduler.xml is found successfully and will be parsed.**
      
      4. If **spark.scheduler.allocation.file** property is not set and **default** fair scheduler file does not exist in classpath, currently, user is not informed so logging can be useful as **No Fair Scheduler file found.**
      
      Also this PR is related with https://github.com/apache/spark/pull/15237 to emphasize fileName in warning logs when fair scheduler file has invalid minShare, weight or schedulingMode values.
      
      ## How was this patch tested?
      Added new Unit Tests.
      
      Author: erenavsarogullari <erenavsarogullari@gmail.com>
      
      Closes #16813 from erenavsarogullari/SPARK-19466.
      dadff5f0
    • Hervé's avatar
      Encryption of shuffle files · c5a66356
      Hervé authored
      Hello
      
      According to my understanding of commits 4b4e329e & 8b325b17, one may now encrypt shuffle files regardless of the cluster manager in use.
      
      However I have limited understanding of the code, I'm not able to find out whether theses changes also comprise all "temporary local storage, such as shuffle files, cached data, and other application files".
      
      Please feel free to amend or reject my PR if I'm wrong.
      
      dud
      
      Author: Hervé <dud225@users.noreply.github.com>
      
      Closes #16885 from dud225/patch-1.
      c5a66356
    • Devaraj K's avatar
      [SPARK-10748][MESOS] Log error instead of crashing Spark Mesos dispatcher when... · 8640dc08
      Devaraj K authored
      [SPARK-10748][MESOS] Log error instead of crashing Spark Mesos dispatcher when a job is misconfigured
      
      ## What changes were proposed in this pull request?
      
      Now handling the spark exception which gets thrown for invalid job configuration, marking that job as failed and continuing to launch the other drivers instead of throwing the exception.
      ## How was this patch tested?
      
      I verified manually, now the misconfigured jobs move to Finished Drivers section in UI and continue to launch the other jobs.
      
      Author: Devaraj K <devaraj@apache.org>
      
      Closes #13077 from devaraj-kavali/SPARK-10748.
      8640dc08
    • jerryshao's avatar
      [SPARK-19545][YARN] Fix compile issue for Spark on Yarn when building against Hadoop 2.6.0~2.6.3 · 8e8afb3a
      jerryshao authored
      ## What changes were proposed in this pull request?
      
      Due to the newly added API in Hadoop 2.6.4+, Spark builds against Hadoop 2.6.0~2.6.3 will meet compile error. So here still reverting back to use reflection to handle this issue.
      
      ## How was this patch tested?
      
      Manual verification.
      
      Author: jerryshao <sshao@hortonworks.com>
      
      Closes #16884 from jerryshao/SPARK-19545.
      8e8afb3a
    • Burak Yavuz's avatar
      [SPARK-19543] from_json fails when the input row is empty · d5593f7f
      Burak Yavuz authored
      ## What changes were proposed in this pull request?
      
      Using from_json on a column with an empty string results in: java.util.NoSuchElementException: head of empty list.
      
      This is because `parser.parse(input)` may return `Nil` when `input.trim.isEmpty`
      
      ## How was this patch tested?
      
      Regression test in `JsonExpressionsSuite`
      
      Author: Burak Yavuz <brkyvz@gmail.com>
      
      Closes #16881 from brkyvz/json-fix.
      d5593f7f
  5. Feb 09, 2017
    • jinxing's avatar
      [SPARK-19263] Fix race in SchedulerIntegrationSuite. · fd6c3a0b
      jinxing authored
      ## What changes were proposed in this pull request?
      
      All the process of offering resource and generating `TaskDescription` should be guarded by taskScheduler.synchronized in `reviveOffers`, otherwise there is race condition.
      
      ## How was this patch tested?
      
      Existing unit tests.
      
      Author: jinxing <jinxing@meituan.com>
      
      Closes #16831 from jinxing64/SPARK-19263-FixRaceInTest.
      fd6c3a0b
    • Shixiong Zhu's avatar
      [SPARK-19481] [REPL] [MAVEN] Avoid to leak SparkContext in Signaling.cancelOnInterrupt · 303f00a4
      Shixiong Zhu authored
      ## What changes were proposed in this pull request?
      
      `Signaling.cancelOnInterrupt` leaks a SparkContext per call and it makes ReplSuite unstable.
      
      This PR adds `SparkContext.getActive` to allow `Signaling.cancelOnInterrupt` to get the active `SparkContext` to avoid the leak.
      
      ## How was this patch tested?
      
      Jenkins
      
      Author: Shixiong Zhu <shixiong@databricks.com>
      
      Closes #16825 from zsxwing/SPARK-19481.
      303f00a4
    • José Hiram Soltren's avatar
      [SPARK-16554][CORE] Automatically Kill Executors and Nodes when they are Blacklisted · 6287c94f
      José Hiram Soltren authored
      ## What changes were proposed in this pull request?
      
      In SPARK-8425, we introduced a mechanism for blacklisting executors and nodes (hosts). After a certain number of failures, these resources would be "blacklisted" and no further work would be assigned to them for some period of time.
      
      In some scenarios, it is better to fail fast, and to simply kill these unreliable resources. This changes proposes to do so by having the BlacklistTracker kill unreliable resources when they would otherwise be "blacklisted".
      
      In order to be thread safe, this code depends on the CoarseGrainedSchedulerBackend sending a message to the driver backend in order to do the actual killing. This also helps to prevent a race which would permit work to begin on a resource (executor or node), between the time the resource is marked for killing and the time at which it is finally killed.
      
      ## How was this patch tested?
      
      ./dev/run-tests
      Ran https://github.com/jsoltren/jose-utils/blob/master/blacklist/test-blacklist.sh, and checked logs to see executors and nodes being killed.
      
      Testing can likely be improved here; suggestions welcome.
      
      Author: José Hiram Soltren <jose@cloudera.com>
      
      Closes #16650 from jsoltren/SPARK-16554-submit.
      6287c94f
    • jiangxingbo's avatar
      [SPARK-19025][SQL] Remove SQL builder for operators · af63c52f
      jiangxingbo authored
      ## What changes were proposed in this pull request?
      
      With the new approach of view resolution, we can get rid of SQL generation on view creation, so let's remove SQL builder for operators.
      
      Note that, since all sql generation for operators is defined in one file (org.apache.spark.sql.catalyst.SQLBuilder), it’d be trivial to recover it in the future.
      
      ## How was this patch tested?
      
      N/A
      
      Author: jiangxingbo <jiangxb1987@gmail.com>
      
      Closes #16869 from jiangxb1987/SQLBuilder.
      af63c52f
    • Bogdan Raducanu's avatar
      [SPARK-19512][SQL] codegen for compare structs fails · 1af0dee4
      Bogdan Raducanu authored
      ## What changes were proposed in this pull request?
      
      Set currentVars to null in GenerateOrdering.genComparisons before genCode is called. genCode ignores INPUT_ROW if currentVars is not null and in genComparisons we want it to use INPUT_ROW.
      
      ## How was this patch tested?
      
      Added test with 2 queries in WholeStageCodegenSuite
      
      Author: Bogdan Raducanu <bogdan.rdc@gmail.com>
      
      Closes #16852 from bogdanrdc/SPARK-19512.
      1af0dee4
    • Ala Luszczak's avatar
      [SPARK-19514] Making range interruptible. · 4064574d
      Ala Luszczak authored
      ## What changes were proposed in this pull request?
      
      Previously range operator could not be interrupted. For example, using DAGScheduler.cancelStage(...) on a query with range might have been ineffective.
      
      This change adds periodic checks of TaskContext.isInterrupted to codegen version, and InterruptibleOperator to non-codegen version.
      
      I benchmarked the performance of codegen version on a sample query `spark.range(1000L * 1000 * 1000 * 10).count()` and there is no measurable difference.
      
      ## How was this patch tested?
      
      Adds a unit test.
      
      Author: Ala Luszczak <ala@databricks.com>
      
      Closes #16872 from ala/SPARK-19514b.
      4064574d
    • Marcelo Vanzin's avatar
      [SPARK-17874][CORE] Add SSL port configuration. · 3fc8e8ca
      Marcelo Vanzin authored
      Make the SSL port configuration explicit, instead of deriving it
      from the non-SSL port, but retain the existing functionality in
      case anyone depends on it.
      
      The change starts the HTTPS and HTTP connectors separately, so
      that it's possible to use independent ports for each. For that to
      work, the initialization of the server needs to be shuffled around
      a bit. The change also makes it so the initialization of both
      connectors is similar, and end up using the same Scheduler - previously
      only the HTTP connector would use the correct one.
      
      Also fixed some outdated documentation about a couple of services
      that were removed long ago.
      
      Tested with unit tests and by running spark-shell with SSL configs.
      
      Author: Marcelo Vanzin <vanzin@cloudera.com>
      
      Closes #16625 from vanzin/SPARK-17874.
      3fc8e8ca
    • Lee Dongjin's avatar
      [MINOR][CORE] Fix incorrect documentation of WritableConverter · 1a09cd63
      Lee Dongjin authored
      ## What changes were proposed in this pull request?
      
      `WritableConverter` and `WritableFactory` work in opposite directions. But both of them are documented with same description:
      
      > A class encapsulating how to convert some type T to Writable. It stores both the Writable class corresponding to T (e.g. IntWritable for Int) and a function for doing the conversion.
      
      This error is a result of commit 2604939f. As a note, `WritableFactory` was added from commit d37978d8, which resolves [SPARK-4795](https://issues.apache.org/jira/browse/SPARK-4795) with the correct description.
      
      This PR fix the documentation of `WritableConverter`, along with some improvements on type description.
      
      ## How was this patch tested?
      
      `build/mvn clean checkstyle:checkstyle`
      
      Author: Lee Dongjin <dongjin@apache.org>
      
      Closes #16830 from dongjinleekr/feature/fix-writableconverter-doc.
      1a09cd63
  6. Feb 08, 2017
    • Liwei Lin's avatar
      [SPARK-19265][SQL][FOLLOW-UP] Configurable `tableRelationCache` maximum size · 9d9d67c7
      Liwei Lin authored
      ## What changes were proposed in this pull request?
      
      SPARK-19265 had made table relation cache general; this follow-up aims to make `tableRelationCache`'s maximum size configurable.
      
      In order to do sanity-check, this patch also adds a `checkValue()` method to `TypedConfigBuilder`.
      
      ## How was this patch tested?
      
      new test case: `test("conf entry: checkValue()")`
      
      Author: Liwei Lin <lwlin7@gmail.com>
      
      Closes #16736 from lw-lin/conf.
      9d9d67c7
    • Wenchen Fan's avatar
      [SPARK-19359][SQL] renaming partition should not leave useless directories · 50a99126
      Wenchen Fan authored
      ## What changes were proposed in this pull request?
      
      Hive metastore is not case-preserving and keep partition columns with lower case names. If Spark SQL creates a table with upper-case partition column names using `HiveExternalCatalog`, when we rename partition, it first calls the HiveClient to renamePartition, which will create a new lower case partition path, then Spark SQL renames the lower case path to upper-case.
      
      However, when we rename a nested path, different file systems have different behaviors. e.g. in jenkins, renaming `a=1/b=2` to `A=2/B=2` will success, but leave an empty directory `a=1`. in mac os, the renaming doesn't work as expected and result to `a=1/B=2`.
      
      This PR renames the partition directory recursively from the first partition column in `HiveExternalCatalog`, to be most compatible with different file systems.
      
      ## How was this patch tested?
      
      new regression test
      
      Author: Wenchen Fan <wenchen@databricks.com>
      
      Closes #16837 from cloud-fan/partition.
      50a99126
    • Dilip Biswal's avatar
      [SPARK-18872][SQL][TESTS] New test cases for EXISTS subquery (Aggregate, Having, Orderby, Limit) · 64cae22f
      Dilip Biswal authored
      ## What changes were proposed in this pull request?
      This PR adds the second set of tests for EXISTS subquery.
      
      File name                        | Brief description
      ------------------------| -----------------
      exists-aggregate.sql              |Tests aggregate expressions in outer query and EXISTS subquery.
      exists-having.sql|Tests HAVING clause in subquery.
      exists-orderby-limit.sql|Tests EXISTS subquery support with ORDER BY and LIMIT clauses.
      
      DB2 results are attached here as reference :
      
      [exists-aggregate-db2.txt](https://github.com/apache/spark/files/743287/exists-aggregate-db2.txt)
      [exists-having-db2.txt](https://github.com/apache/spark/files/743286/exists-having-db2.txt)
      [exists-orderby-limit-db2.txt](https://github.com/apache/spark/files/743288/exists-orderby-limit-db2.txt)
      
      ##  How the patch was tested.
      The test result is compared with the result run from another SQL engine (in this case is IBM DB2). If the result are equivalent, we assume the result is correct.
      
      Author: Dilip Biswal <dbiswal@us.ibm.com>
      
      Closes #16760 from dilipbiswal/exists-pr2.
      64cae22f
    • Dongjoon Hyun's avatar
      [SPARK-19464][BUILD][HOTFIX] run-tests should use hadoop2.6 · c618ccdb
      Dongjoon Hyun authored
      ## What changes were proposed in this pull request?
      
      After SPARK-19464, **SparkPullRequestBuilder** fails because it still tries to use hadoop2.3.
      
      **BEFORE**
      https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/72595/console
      ```
      ========================================================================
      Building Spark
      ========================================================================
      [error] Could not find hadoop2.3 in the list. Valid options  are ['hadoop2.6', 'hadoop2.7']
      Attempting to post to Github...
       > Post successful.
      ```
      
      **AFTER**
      https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/72595/console
      ```
      ========================================================================
      Building Spark
      ========================================================================
      [info] Building Spark (w/Hive 1.2.1) using SBT with these arguments:  -Phadoop-2.6 -Pmesos -Pkinesis-asl -Pyarn -Phive-thriftserver -Phive test:package streaming-kafka-0-8-assembly/assembly streaming-flume-assembly/assembly streaming-kinesis-asl-assembly/assembly
      Using /usr/java/jdk1.8.0_60 as default JAVA_HOME.
      Note, this will be overridden by -java-home if it is set.
      ```
      
      ## How was this patch tested?
      
      Pass the existing test.
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #16858 from dongjoon-hyun/hotfix_run-tests.
      c618ccdb
    • actuaryzhang's avatar
      [SPARK-19400][ML] Allow GLM to handle intercept only model · 1aeb9f6c
      actuaryzhang authored
      ## What changes were proposed in this pull request?
      Intercept-only GLM is failing for non-Gaussian family because of reducing an empty array in IWLS. The following code `val maxTolOfCoefficients = oldCoefficients.toArray.reduce { (x, y) => math.max(math.abs(x), math.abs(y))` fails in the intercept-only model because `oldCoefficients` is empty. This PR fixes this issue.
      
      yanboliang srowen imatiach-msft zhengruifeng
      
      ## How was this patch tested?
      New test for intercept only model.
      
      Author: actuaryzhang <actuaryzhang10@gmail.com>
      
      Closes #16740 from actuaryzhang/interceptOnly.
      1aeb9f6c
    • Sean Owen's avatar
      [SPARK-19464][BUILD][HOTFIX][TEST-HADOOP2.6] Add back mockito test dep in YARN... · 15627ac7
      Sean Owen authored
      [SPARK-19464][BUILD][HOTFIX][TEST-HADOOP2.6] Add back mockito test dep in YARN module, as it ends up being required in a Maven build
      
      Add back mockito test dep in YARN module, as it ends up being required in a Maven build
      
      ## How was this patch tested?
      
      PR builder again, but also a local `mvn` run using the command that the broken Jenkins job uses
      
      Author: Sean Owen <sowen@cloudera.com>
      
      Closes #16853 from srowen/SPARK-19464.2.
      15627ac7
    • gatorsmile's avatar
      [SPARK-19279][SQL][FOLLOW-UP] Infer Schema for Hive Serde Tables · 4d4d0de7
      gatorsmile authored
      ### What changes were proposed in this pull request?
      `table.schema` is always not empty for partitioned tables, because `table.schema` also contains the partitioned columns, even if the original table does not have any column. This PR is to fix the issue.
      
      ### How was this patch tested?
      Added a test case
      
      Author: gatorsmile <gatorsmile@gmail.com>
      
      Closes #16848 from gatorsmile/inferHiveSerdeSchema.
      4d4d0de7
    • Dongjoon Hyun's avatar
      [SPARK-19409][BUILD][TEST-MAVEN] Fix ParquetAvroCompatibilitySuite failure due... · 0077bfcb
      Dongjoon Hyun authored
      [SPARK-19409][BUILD][TEST-MAVEN] Fix ParquetAvroCompatibilitySuite failure due to test dependency on avro
      
      ## What changes were proposed in this pull request?
      
      After using Apache Parquet 1.8.2, `ParquetAvroCompatibilitySuite` fails on **Maven** test. It is because `org.apache.parquet.avro.AvroParquetWriter` in the test code used new `avro 1.8.0` specific class, `LogicalType`. This PR aims to fix the test dependency of `sql/core` module to use avro 1.8.0.
      
      https://amplab.cs.berkeley.edu/jenkins/view/Spark%20QA%20Test%20(Dashboard)/job/spark-master-test-maven-hadoop-2.7/2530/consoleFull
      
      ```
      ParquetAvroCompatibilitySuite:
      *** RUN ABORTED ***
        java.lang.NoClassDefFoundError: org/apache/avro/LogicalType
        at org.apache.parquet.avro.AvroParquetWriter.writeSupport(AvroParquetWriter.java:144)
      ```
      
      ## How was this patch tested?
      
      Pass the existing test with **Maven**.
      
      ```
      $ build/mvn -Pyarn -Phadoop-2.7 -Pkinesis-asl -Phive -Phive-thriftserver test
      ...
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 02:07 h
      [INFO] Finished at: 2017-02-04T05:41:43+00:00
      [INFO] Final Memory: 77M/987M
      [INFO] ------------------------------------------------------------------------
      ```
      
      Author: Dongjoon Hyun <dongjoon@apache.org>
      
      Closes #16795 from dongjoon-hyun/SPARK-19409-2.
      0077bfcb
    • Sean Owen's avatar
      [SPARK-19464][CORE][YARN][TEST-HADOOP2.6] Remove support for Hadoop 2.5 and earlier · e8d3fca4
      Sean Owen authored
      ## What changes were proposed in this pull request?
      
      - Remove support for Hadoop 2.5 and earlier
      - Remove reflection and code constructs only needed to support multiple versions at once
      - Update docs to reflect newer versions
      - Remove older versions' builds and profiles.
      
      ## How was this patch tested?
      
      Existing tests
      
      Author: Sean Owen <sowen@cloudera.com>
      
      Closes #16810 from srowen/SPARK-19464.
      e8d3fca4
    • windpiger's avatar
      [SPARK-19488][SQL] fix csv infer schema when the field is Nan/Inf etc · d60dde26
      windpiger authored
      ## What changes were proposed in this pull request?
      
      when csv infer schema, it does not use user defined csvoptions to parse the field, such as `inf`, `-inf` which are should be parsed to DoubleType
      
      this pr add  `options.nanValue`, `options.negativeInf`, `options.positiveIn`  to check if the field is a DoubleType
      
      ## How was this patch tested?
      unit test added
      
      Author: windpiger <songjun@outlook.com>
      
      Closes #16834 from windpiger/fixinferInfSchemaCsv.
      d60dde26
  7. Feb 07, 2017
    • manugarri's avatar
      [MINOR][DOC] Remove parenthesis in readStream() on kafka structured streaming doc · 5a0569ce
      manugarri authored
      There is a typo in http://spark.apache.org/docs/latest/structured-streaming-kafka-integration.html#creating-a-kafka-source-stream , python example n1 uses `readStream()` instead of `readStream`
      
      Just removed the parenthesis.
      
      Author: manugarri <manuel.garrido.pena@gmail.com>
      
      Closes #16836 from manugarri/fix_kafka_python_doc.
      5a0569ce
    • Nattavut Sutyanyong's avatar
      [SPARK-18873][SQL][TEST] New test cases for scalar subquery (part 1 of 2) -... · 266c1e73
      Nattavut Sutyanyong authored
      [SPARK-18873][SQL][TEST] New test cases for scalar subquery (part 1 of 2) - scalar subquery in SELECT clause
      
      ## What changes were proposed in this pull request?
      This PR adds new test cases for scalar subquery in SELECT clause.
      
      ## How was this patch tested?
      The test result is compared with the result run from another SQL engine (in this case is IBM DB2). If the result are equivalent, we assume the result is correct.
      
      Author: Nattavut Sutyanyong <nsy.can@gmail.com>
      
      Closes #16712 from nsyca/18873.
      266c1e73
    • CodingCat's avatar
      [SPARK-19499][SS] Add more notes in the comments of Sink.addBatch() · d4cd9757
      CodingCat authored
      ## What changes were proposed in this pull request?
      
      addBatch method in Sink trait is supposed to be a synchronous method to coordinate with the fault-tolerance design in StreamingExecution (being different with the compute() method in DStream)
      
      We need to add more notes in the comments of this method to remind the developers
      
      ## How was this patch tested?
      
      existing tests
      
      Author: CodingCat <zhunansjtu@gmail.com>
      
      Closes #16840 from CodingCat/SPARK-19499.
      d4cd9757
    • Tathagata Das's avatar
      [SPARK-19413][SS] MapGroupsWithState for arbitrary stateful operations · aeb80348
      Tathagata Das authored
      ## What changes were proposed in this pull request?
      
      `mapGroupsWithState` is a new API for arbitrary stateful operations in Structured Streaming, similar to `DStream.mapWithState`
      
      *Requirements*
      - Users should be able to specify a function that can do the following
      - Access the input row corresponding to a key
      - Access the previous state corresponding to a key
      - Optionally, update or remove the state
      - Output any number of new rows (or none at all)
      
      *Proposed API*
      ```
      // ------------ New methods on KeyValueGroupedDataset ------------
      class KeyValueGroupedDataset[K, V] {
      	// Scala friendly
      	def mapGroupsWithState[S: Encoder, U: Encoder](func: (K, Iterator[V], KeyedState[S]) => U)
              def flatMapGroupsWithState[S: Encode, U: Encoder](func: (K, Iterator[V], KeyedState[S]) => Iterator[U])
      	// Java friendly
             def mapGroupsWithState[S, U](func: MapGroupsWithStateFunction[K, V, S, R], stateEncoder: Encoder[S], resultEncoder: Encoder[U])
             def flatMapGroupsWithState[S, U](func: FlatMapGroupsWithStateFunction[K, V, S, R], stateEncoder: Encoder[S], resultEncoder: Encoder[U])
      }
      
      // ------------------- New Java-friendly function classes -------------------
      public interface MapGroupsWithStateFunction<K, V, S, R> extends Serializable {
        R call(K key, Iterator<V> values, state: KeyedState<S>) throws Exception;
      }
      public interface FlatMapGroupsWithStateFunction<K, V, S, R> extends Serializable {
        Iterator<R> call(K key, Iterator<V> values, state: KeyedState<S>) throws Exception;
      }
      
      // ---------------------- Wrapper class for state data ----------------------
      trait State[S] {
      	def exists(): Boolean
        	def get(): S 			// throws Exception is state does not exist
      	def getOption(): Option[S]
      	def update(newState: S): Unit
      	def remove(): Unit		// exists() will be false after this
      }
      ```
      
      Key Semantics of the State class
      - The state can be null.
      - If the state.remove() is called, then state.exists() will return false, and getOption will returm None.
      - After that state.update(newState) is called, then state.exists() will return true, and getOption will return Some(...).
      - None of the operations are thread-safe. This is to avoid memory barriers.
      
      *Usage*
      ```
      val stateFunc = (word: String, words: Iterator[String, runningCount: KeyedState[Long]) => {
          val newCount = words.size + runningCount.getOption.getOrElse(0L)
          runningCount.update(newCount)
         (word, newCount)
      }
      
      dataset					                        // type is Dataset[String]
        .groupByKey[String](w => w)        	                // generates KeyValueGroupedDataset[String, String]
        .mapGroupsWithState[Long, (String, Long)](stateFunc)	// returns Dataset[(String, Long)]
      ```
      
      ## How was this patch tested?
      New unit tests.
      
      Author: Tathagata Das <tathagata.das1565@gmail.com>
      
      Closes #16758 from tdas/mapWithState.
      aeb80348
    • gatorsmile's avatar
      [SPARK-19397][SQL] Make option names of LIBSVM and TEXT case insensitive · e33aaa2a
      gatorsmile authored
      ### What changes were proposed in this pull request?
      Prior to Spark 2.1, the option names are case sensitive for all the formats. Since Spark 2.1, the option key names become case insensitive except the format `Text` and `LibSVM `. This PR is to fix these issues.
      
      Also, add a check to know whether the input option vector type is legal for `LibSVM`.
      
      ### How was this patch tested?
      Added test cases
      
      Author: gatorsmile <gatorsmile@gmail.com>
      
      Closes #16737 from gatorsmile/libSVMTextOptions.
      e33aaa2a
    • Tyson Condie's avatar
      [SPARK-18682][SS] Batch Source for Kafka · 8df44440
      Tyson Condie authored
      ## What changes were proposed in this pull request?
      
      Today, you can start a stream that reads from kafka. However, given kafka's configurable retention period, it seems like sometimes you might just want to read all of the data that is available now. As such we should add a version that works with spark.read as well.
      The options should be the same as the streaming kafka source, with the following differences:
      startingOffsets should default to earliest, and should not allow latest (which would always be empty).
      endingOffsets should also be allowed and should default to latest. the same assign json format as startingOffsets should also be accepted.
      It would be really good, if things like .limit(n) were enough to prevent all the data from being read (this might just work).
      
      ## How was this patch tested?
      
      KafkaRelationSuite was added for testing batch queries via KafkaUtils.
      
      Author: Tyson Condie <tcondie@gmail.com>
      
      Closes #16686 from tcondie/SPARK-18682.
      8df44440
    • Herman van Hovell's avatar
      [SPARK-18609][SPARK-18841][SQL] Fix redundant Alias removal in the optimizer · 73ee7394
      Herman van Hovell authored
      ## What changes were proposed in this pull request?
      The optimizer tries to remove redundant alias only projections from the query plan using the `RemoveAliasOnlyProject` rule. The current rule identifies removes such a project and rewrites the project's attributes in the **entire** tree. This causes problems when parts of the tree are duplicated (for instance a self join on a temporary view/CTE)  and the duplicated part contains the alias only project, in this case the rewrite will break the tree.
      
      This PR fixes these problems by using a blacklist for attributes that are not to be moved, and by making sure that attribute remapping is only done for the parent tree, and not for unrelated parts of the query plan.
      
      The current tree transformation infrastructure works very well if the transformation at hand requires little or a global contextual information. In this case we need to know both the attributes that were not to be moved, and we also needed to know which child attributes were modified. This cannot be done easily using the current infrastructure, and solutions typically involves transversing the query plan multiple times (which is super slow). I have moved around some code in `TreeNode`, `QueryPlan` and `LogicalPlan`to make this much more straightforward; this basically allows you to manually traverse the tree.
      
      This PR subsumes the following PRs by windpiger:
      Closes https://github.com/apache/spark/pull/16267
      Closes https://github.com/apache/spark/pull/16255
      
      ## How was this patch tested?
      I have added unit tests to `RemoveRedundantAliasAndProjectSuite` and I have added integration tests to the `SQLQueryTestSuite.union` and `SQLQueryTestSuite.cte` test cases.
      
      Author: Herman van Hovell <hvanhovell@databricks.com>
      
      Closes #16757 from hvanhovell/SPARK-18609.
      73ee7394
    • Reynold Xin's avatar
      [SPARK-19495][SQL] Make SQLConf slightly more extensible · b7277e03
      Reynold Xin authored
      ## What changes were proposed in this pull request?
      This pull request makes SQLConf slightly more extensible by removing the visibility limitations on the build* functions.
      
      ## How was this patch tested?
      N/A - there are no logic changes and everything should be covered by existing unit tests.
      
      Author: Reynold Xin <rxin@databricks.com>
      
      Closes #16835 from rxin/SPARK-19495.
      b7277e03
    • anabranch's avatar
      [SPARK-16609] Add to_date/to_timestamp with format functions · 7a7ce272
      anabranch authored
      ## What changes were proposed in this pull request?
      
      This pull request adds two new user facing functions:
      - `to_date` which accepts an expression and a format and returns a date.
      - `to_timestamp` which accepts an expression and a format and returns a timestamp.
      
      For example, Given a date in format: `2016-21-05`. (YYYY-dd-MM)
      
      ### Date Function
      *Previously*
      ```
      to_date(unix_timestamp(lit("2016-21-05"), "yyyy-dd-MM").cast("timestamp"))
      ```
      *Current*
      ```
      to_date(lit("2016-21-05"), "yyyy-dd-MM")
      ```
      
      ### Timestamp Function
      *Previously*
      ```
      unix_timestamp(lit("2016-21-05"), "yyyy-dd-MM").cast("timestamp")
      ```
      *Current*
      ```
      to_timestamp(lit("2016-21-05"), "yyyy-dd-MM")
      ```
      ### Tasks
      
      - [X] Add `to_date` to Scala Functions
      - [x] Add `to_date` to Python Functions
      - [x] Add `to_date` to SQL Functions
      - [X] Add `to_timestamp` to Scala Functions
      - [x] Add `to_timestamp` to Python Functions
      - [x] Add `to_timestamp` to SQL Functions
      - [x] Add function to R
      
      ## How was this patch tested?
      
      - [x] Add Functions to `DateFunctionsSuite`
      - Test new `ParseToTimestamp` Expression (*not necessary*)
      - Test new `ParseToDate` Expression (*not necessary*)
      - [x] Add test for R
      - [x] Add test for Python in test.py
      
      Please review http://spark.apache.org/contributing.html before opening a pull request.
      
      Author: anabranch <wac.chambers@gmail.com>
      Author: Bill Chambers <bill@databricks.com>
      Author: anabranch <bill@databricks.com>
      
      Closes #16138 from anabranch/SPARK-16609.
      7a7ce272
Loading