Skip to content

Instantly share code, notes, and snippets.

@MrJaba
Created July 5, 2012 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MrJaba/3053815 to your computer and use it in GitHub Desktop.
Save MrJaba/3053815 to your computer and use it in GitHub Desktop.
Cascalog JDBCTap Example
(defn query-params []
(into-array String ["?col1" "?col2"]))
(defn column-names []
(into-array String ["col1" "col2"]))
; Becomes the 'where' part of the UPDATE statement - use primary key for example
(defn update-params []
(into-array String ["?col1"]))
; Becomes the 'where' part of the UPDATE statement
(defn update-column-names []
(into-array String ["col1"]))
(defn jdbc-tap []
(let [scheme (JDBCScheme. (Fields. (query-params)) (column-names) nil (Fields. (update-params)) (update-column-names))
table-desc (TableDesc. "table_name" (query-params) (column-names) (into-array String []))
tap (JDBCTap. "jdbc:mysql://localhost:3306/burn?user=root&password=" "com.mysql.jdbc.Driver" table-desc scheme )]
tap))
(defn write []
(?<- (jdbc-tap) [?col1 ?col2] (tuple-source-tap ?col1 ?col2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment