Trying to understand "trait QueryAST" in Lightweight Modular Staging (LMS) examples

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to understand "trait QueryAST" in Lightweight Modular Staging (LMS) examples

ssarkarayushnetdev
Hello,

I am trying to understand and change SQL query compiler in LMS (https://scala-lms.github.io/tutorials/query.html).

I am trying to understand all the places I need to change if I add new operators in QueryAST for an extended SQL syntax :

trait QueryAST {
  type Table
  type Schema = Vector[String]

  // relational algebra ops
  sealed abstract class Operator
  case class Scan(name: Table, schema: Schema, delim: Char, extSchema: Boolean) extends Operator
  case class PrintCSV(parent: Operator) extends Operator
  case class Project(outSchema: Schema, inSchema: Schema, parent: Operator) extends Operator
  case class Filter(pred: Predicate, parent: Operator) extends Operator
  case class Join(parent1: Operator, parent2: Operator) extends Operator
  case class Group(keys: Schema, agg: Schema, parent: Operator) extends Operator
  case class HashJoin(parent1: Operator, parent2: Operator) extends Operator

  // filter predicates
  sealed abstract class Predicate
  case class Eq(a: Ref, b: Ref) extends Predicate

  sealed abstract class Ref
  case class Field(name: String) extends Ref
  case class Value(x: Any) extends Ref

  // some smart constructors
  def Schema(schema: String*): Schema = schema.toVector
  def Scan(tableName: String): Scan = Scan(tableName, None, None)
  def Scan(tableName: String, schema: Option[Schema], delim: Option[Char]): Scan
}

I know that I have to change in SQL parser.
Do I need to change anything in
scala.lms.common._ or any other places ?

Any help will be appreciated.

Thanks,
S. Sarkar




--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trying to understand "trait QueryAST" in Lightweight Modular Staging (LMS) examples

Jasper-M
I don't know anything about this library, but I think since Operator is sealed, you will probably get exhaustiveness warnings in most places that need to be changed.

Op maandag 23 januari 2017 22:34:05 UTC+1 schreef [hidden email]:
Hello,

I am trying to understand and change SQL query compiler in LMS (<a href="https://scala-lms.github.io/tutorials/query.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fscala-lms.github.io%2Ftutorials%2Fquery.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEH8fX739ZP1L3HP2wFJNGPD3m-Bw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fscala-lms.github.io%2Ftutorials%2Fquery.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEH8fX739ZP1L3HP2wFJNGPD3m-Bw&#39;;return true;">https://scala-lms.github.io/tutorials/query.html).

I am trying to understand all the places I need to change if I add new operators in QueryAST for an extended SQL syntax :

trait QueryAST {
  type Table
  type Schema = Vector[String]

  // relational algebra ops
  sealed abstract class Operator
  case class Scan(name: Table, schema: Schema, delim: Char, extSchema: Boolean) extends Operator
  case class PrintCSV(parent: Operator) extends Operator
  case class Project(outSchema: Schema, inSchema: Schema, parent: Operator) extends Operator
  case class Filter(pred: Predicate, parent: Operator) extends Operator
  case class Join(parent1: Operator, parent2: Operator) extends Operator
  case class Group(keys: Schema, agg: Schema, parent: Operator) extends Operator
  case class HashJoin(parent1: Operator, parent2: Operator) extends Operator

  // filter predicates
  sealed abstract class Predicate
  case class Eq(a: Ref, b: Ref) extends Predicate

  sealed abstract class Ref
  case class Field(name: String) extends Ref
  case class Value(x: Any) extends Ref

  // some smart constructors
  def Schema(schema: String*): Schema = schema.toVector
  def Scan(tableName: String): Scan = Scan(tableName, None, None)
  def Scan(tableName: String, schema: Option[Schema], delim: Option[Char]): Scan
}

I know that I have to change in SQL parser.
Do I need to change anything in
scala.lms.common._ or any other places ?

Any help will be appreciated.

Thanks,
S. Sarkar




--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.