Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.apache.spark.sql.hbase.logical

import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan, Command}
import org.apache.spark.sql.hbase.HBaseRelation

import org.apache.spark.sql.catalyst.plans.logical.{UnaryNode, LeafNode, LogicalPlan, Command}
//import org.apache.spark.sql.hbase.HBaseRelation
/*
case class CreateHBaseTablePlan(tableName: String,
nameSpace: String,
hbaseTable: String,
Expand All @@ -20,8 +20,13 @@ case class BulkLoadIntoTable(
// TODO:need resolved here?

}
*/
case class LoadDataIntoTable(path: String,
child: LogicalPlan,
isLocal: Boolean) extends UnaryNode {

case class LoadDataIntoTable(path: String, table: String, isLocal: Boolean) extends LeafNode {
override def output = Seq.empty
override def output = Nil

override def toString = s"LogicalPlan: LoadDataIntoTable(LOAD $path INTO $child)"
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ package org.apache.spark.sql.hbase
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.{SqlLexical, SqlParser}
import org.apache.spark.sql.hbase.logical._

class HBaseSQLParser extends SqlParser {

protected val DATA = Keyword("DATA")
protected val LOAD = Keyword("LOAD")
protected val LOCAL = Keyword("LOCAL")
protected val INPATH = Keyword("INPATH")

protected val BULK = Keyword("BULK")
protected val CREATE = Keyword("CREATE")
protected val DROP = Keyword("DROP")
Expand Down Expand Up @@ -53,9 +60,10 @@ class HBaseSQLParser extends SqlParser {
| EXCEPT ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Except(q1, q2)}
| UNION ~ DISTINCT.? ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Distinct(Union(q1, q2))}
)
| insert | create | drop | alter
| load
/* | insert | create | drop | alter */
)

/*
override protected lazy val insert: Parser[LogicalPlan] =
INSERT ~> INTO ~> relation ~ select <~ opt(";") ^^ {
case r ~ s =>
Expand Down Expand Up @@ -121,6 +129,7 @@ class HBaseSQLParser extends SqlParser {

CreateHBaseTablePlan(tableName, customizedNameSpace, hbaseTableName,
tableColumns.unzip._1, keyColsWithDataType, nonKeyCols)

}

protected lazy val drop: Parser[LogicalPlan] =
Expand All @@ -134,6 +143,12 @@ class HBaseSQLParser extends SqlParser {
} | ALTER ~> TABLE ~> ident ~ ADD ~ tableCol ~ (MAPPED ~> BY ~> "(" ~> expressions <~ ")") ^^ {
case tn ~ op ~ tc ~ cf => null
}
*/
protected lazy val load: Parser[LogicalPlan] =
(LOAD ~> DATA ~> opt(LOCAL) ~> INPATH ~> ident) ~
(opt(OVERWRITE) ~> INTO ~> TABLE ~> relation) ^^ {
case filePath ~ table => LoadDataIntoTable(filePath, table, true)
}

protected lazy val tableCol: Parser[(String, String)] =
ident ~ (STRING | BYTE | SHORT | INTEGER | LONG | FLOAT | DOUBLE | BOOLEAN) ^^ {
Expand Down