Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 2.17 KB | None | 0 0
  1. import com.myuan.transsql._
  2.  
  3. import com.myuan.transsql.query.BaseCommand
  4.  
  5. object main {
  6.  
  7.    def main(args: Array[String]): Unit = {
  8.     val teraSQL : String = """CREATE  volatile TABLE table3, no logs, AS (sel id_num AS new_id, family_id, birth_dt, wake_tm, col1 FROM table1 WHERE rel_type (NOT cs) LIKE 'Matt%'
  9.                             |AND
  10.                             |birth_dt >= date - 60
  11.                             |AND
  12.                             |(
  13.                             |  friend1,friend2
  14.                             |)
  15.                             |IN (sel friend1,
  16.                             |    friend2 FROM ${schema2}.table4 WHERE home_type='house' GROUP BY 1,
  17.                             |    2)
  18.                             |AND
  19.                             |upper (trim (id_num))(casespecific) = lower (trim (id_num))(casespecific ) qualify rank() OVER (partition BY id_num ORDER BY birth_dt ASC , wake_tm ASC) = 1
  20.                             |UNION
  21.                             |         sel id_num AS new_id,
  22.                             |         family_id,
  23.                             |         birth_dt,
  24.                             |         wake_tm,
  25.                             |         col1
  26.                             |FROM     table10
  27.                             |WHERE    NAME (NOT cs)
  28.                             |AND      birth_dt >= date - 60AND upper (trim (id_num))(casespecific) = lower (trim (id_num))(casespecific ) qualify rank() OVER (partition BY id_num ORDER BY birth_dt ASC , wake_tm ASC) = 1) WITH data PRIMARY INDEX(new_id) ONCOMMIT preserve rows""".stripMargin
  29.      val comm: BaseCommand = QueryParser.getCommand(teraSQL)
  30.  
  31.     var ansiSQL : String = ""
  32.  
  33.     comm.parse(teraSQL)
  34.  
  35.     ansiSQL = comm.toSQL()
  36.  
  37.      println(Console.BLUE + "Printing Teradata SQL Input")
  38.      println(Console.WHITE + teraSQL)
  39.      println(Console.BLUE + "Printing ANSI SQL")
  40.      println(Console.WHITE + ansiSQL)
  41.      println(Console.BLUE + "Printing SQL dependencies")
  42.      println(Console.WHITE + comm.showDependency())
  43.      println(Console.BLUE + "Printing SQL stats")
  44.      println(Console.WHITE + comm.showStats())
  45.   }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement