[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/spark/pull/15518


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread ericl
Github user ericl commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83747245
  
--- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetPartitionDiscoverySuite.scala
 ---
@@ -626,8 +626,9 @@ class ParquetPartitionDiscoverySuite extends QueryTest 
with ParquetTest with Sha
   (1 to 10).map(i => (i, i.toString)).toDF("a", 
"b").write.parquet(dir.getCanonicalPath)
   val queryExecution = 
spark.read.parquet(dir.getCanonicalPath).queryExecution
   queryExecution.analyzed.collectFirst {
-case LogicalRelation(HadoopFsRelation(location: FileCatalog, _, _, 
_, _, _), _, _) =>
-  assert(location.partitionSpec === PartitionSpec.emptySpec)
+case LogicalRelation(
+HadoopFsRelation(location: PartitioningAwareFileCatalog, _, _, 
_, _, _), _, _) =>
+  assert(location.partitionSpec() === PartitionSpec.emptySpec)
   }.getOrElse {
 fail(s"Expecting a ParquetRelation2, but got:\n$queryExecution")
--- End diff --

Changed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread ericl
Github user ericl commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83747236
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileCatalog.scala
 ---
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.datasources
+
+import org.apache.hadoop.fs._
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+
+/**
+ * A collection of data files from a partitioned relation, along with the 
partition values in the
+ * form of an [[InternalRow]].
+ */
+case class Partition(values: InternalRow, files: Seq[FileStatus])
+
+/**
+ * An interface for objects capable of enumerating the root paths of a 
relation as well as the
+ * partitions of a relation subject to some pruning expressions.
+ */
+trait FileCatalog {
+
+  /**
+   * Returns the list of root input paths from which the catalog will get 
files. There may be a
+   * single root path from which partitions are discovered, or individual 
partitions may be
+   * specified by each path.
+   */
+  def rootPaths: Seq[Path]
--- End diff --

I think they are the roots of the recursive traversal to discover leaf 
files. I am inclined to keep `rootPaths` since it's easy to grep for, vs 
`paths` which is too common.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread ericl
Github user ericl commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83747244
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileCatalog.scala
 ---
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.datasources
+
+import org.apache.hadoop.fs._
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+
+/**
+ * A collection of data files from a partitioned relation, along with the 
partition values in the
+ * form of an [[InternalRow]].
+ */
+case class Partition(values: InternalRow, files: Seq[FileStatus])
--- End diff --

I don't think these are the partitions tasks see. Confusingly, those seem 
to be named `FilePartition`. How about `PartitionFiles`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread mallman
Github user mallman commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83741391
  
--- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetPartitionDiscoverySuite.scala
 ---
@@ -626,8 +626,9 @@ class ParquetPartitionDiscoverySuite extends QueryTest 
with ParquetTest with Sha
   (1 to 10).map(i => (i, i.toString)).toDF("a", 
"b").write.parquet(dir.getCanonicalPath)
   val queryExecution = 
spark.read.parquet(dir.getCanonicalPath).queryExecution
   queryExecution.analyzed.collectFirst {
-case LogicalRelation(HadoopFsRelation(location: FileCatalog, _, _, 
_, _, _), _, _) =>
-  assert(location.partitionSpec === PartitionSpec.emptySpec)
+case LogicalRelation(
+HadoopFsRelation(location: PartitioningAwareFileCatalog, _, _, 
_, _, _), _, _) =>
+  assert(location.partitionSpec() === PartitionSpec.emptySpec)
   }.getOrElse {
 fail(s"Expecting a ParquetRelation2, but got:\n$queryExecution")
--- End diff --

We're not expecting a `ParquetRelation2` anymore—more like a 
`HadoopFsRelation` with a `PartitioningAwareFileCatalog`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread mallman
Github user mallman commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83738938
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileCatalog.scala
 ---
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.datasources
+
+import org.apache.hadoop.fs._
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+
+/**
+ * A collection of data files from a partitioned relation, along with the 
partition values in the
+ * form of an [[InternalRow]].
+ */
+case class Partition(values: InternalRow, files: Seq[FileStatus])
+
+/**
+ * An interface for objects capable of enumerating the root paths of a 
relation as well as the
+ * partitions of a relation subject to some pruning expressions.
+ */
+trait FileCatalog {
+
+  /**
+   * Returns the list of root input paths from which the catalog will get 
files. There may be a
+   * single root path from which partitions are discovered, or individual 
partitions may be
+   * specified by each path.
+   */
+  def rootPaths: Seq[Path]
--- End diff --

I would say "pretty much nothing" anymore.

In an earlier version, it was the "root" path of the table, excluding any 
partition dirs. The PR drifted away from that definition.

Now I'd say it could be reverted to `paths`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread rxin
Github user rxin commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83738846
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileCatalog.scala
 ---
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.datasources
+
+import org.apache.hadoop.fs._
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+
+/**
+ * A collection of data files from a partitioned relation, along with the 
partition values in the
+ * form of an [[InternalRow]].
+ */
+case class Partition(values: InternalRow, files: Seq[FileStatus])
--- End diff --

while you are doing it, perhaps we can rename this TaskPartition? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread rxin
Github user rxin commented on a diff in the pull request:

https://github.com/apache/spark/pull/15518#discussion_r83737706
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileCatalog.scala
 ---
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.datasources
+
+import org.apache.hadoop.fs._
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+
+/**
+ * A collection of data files from a partitioned relation, along with the 
partition values in the
+ * form of an [[InternalRow]].
+ */
+case class Partition(values: InternalRow, files: Seq[FileStatus])
+
+/**
+ * An interface for objects capable of enumerating the root paths of a 
relation as well as the
+ * partitions of a relation subject to some pruning expressions.
+ */
+trait FileCatalog {
+
+  /**
+   * Returns the list of root input paths from which the catalog will get 
files. There may be a
+   * single root path from which partitions are discovered, or individual 
partitions may be
+   * specified by each path.
+   */
+  def rootPaths: Seq[Path]
--- End diff --

what's "root" about this?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #15518: [SPARK-17974] Refactor FileCatalog classes to sim...

2016-10-17 Thread ericl
GitHub user ericl opened a pull request:

https://github.com/apache/spark/pull/15518

[SPARK-17974] Refactor FileCatalog classes to simplify the inheritance tree

## What changes were proposed in this pull request?

This renames `BasicFileCatalog => FileCatalog`, combines  
`SessionFileCatalog` with `PartitioningAwareFileCatalog`, and removes the old 
`FileCatalog` trait.

In summary,
```
MetadataLogFileCatalog extends PartitioningAwareFileCatalog
ListingFileCatalog extends PartitioningAwareFileCatalog
PartitioningAwareFileCatalog extends FileCatalog
TableFileCatalog extends FileCatalog
```

cc @cloud-fan @mallman 

## How was this patch tested?

Existing tests

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ericl/spark refactor-session-file-catalog

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/15518.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #15518


commit 798a8820c074e17b1eb17ca4446c7eb0969c63c8
Author: Eric Liang 
Date:   2016-10-17T18:30:30Z

move files

commit db8a669bc1c51fef97e231cc5fec4eb9523b9c47
Author: Eric Liang 
Date:   2016-10-17T18:31:42Z

Mon Oct 17 11:31:42 PDT 2016

commit e2d8c1d850bfaa30dd4b598d284f6068044c46cd
Author: Eric Liang 
Date:   2016-10-17T19:05:47Z

clean up classes

commit 5d390c97f61af4d84c194344d8dd4c86fb41eb32
Author: Eric Liang 
Date:   2016-10-17T19:08:28Z

merge suites




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org