@databricks/sql 0.1.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/.gitattributes +32 -0
  2. package/CHANGELOG.md +1 -0
  3. package/CONTRIBUTING.md +55 -0
  4. package/LICENSE +201 -0
  5. package/README.md +78 -0
  6. package/dist/DBSQLClient.d.ts +42 -0
  7. package/dist/DBSQLClient.js +111 -0
  8. package/dist/DBSQLClient.js.map +1 -0
  9. package/dist/HiveClient.d.ts +35 -0
  10. package/dist/HiveClient.js +156 -0
  11. package/dist/HiveClient.js.map +1 -0
  12. package/dist/HiveOperation.d.ts +65 -0
  13. package/dist/HiveOperation.js +190 -0
  14. package/dist/HiveOperation.js.map +1 -0
  15. package/dist/HiveSession.d.ts +30 -0
  16. package/dist/HiveSession.js +197 -0
  17. package/dist/HiveSession.js.map +1 -0
  18. package/dist/connection/auth/NoSaslAuthentication.d.ts +5 -0
  19. package/dist/connection/auth/NoSaslAuthentication.js +15 -0
  20. package/dist/connection/auth/NoSaslAuthentication.js.map +1 -0
  21. package/dist/connection/auth/PlainHttpAuthentication.d.ts +15 -0
  22. package/dist/connection/auth/PlainHttpAuthentication.js +30 -0
  23. package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -0
  24. package/dist/connection/auth/helpers/SaslPackageFactory.d.ts +11 -0
  25. package/dist/connection/auth/helpers/SaslPackageFactory.js +24 -0
  26. package/dist/connection/auth/helpers/SaslPackageFactory.js.map +1 -0
  27. package/dist/connection/connections/HttpConnection.d.ts +13 -0
  28. package/dist/connection/connections/HttpConnection.js +77 -0
  29. package/dist/connection/connections/HttpConnection.js.map +1 -0
  30. package/dist/connection/contracts/IAuthentication.d.ts +4 -0
  31. package/dist/connection/contracts/IAuthentication.js +3 -0
  32. package/dist/connection/contracts/IAuthentication.js.map +1 -0
  33. package/dist/connection/contracts/IConnectionOptions.d.ts +23 -0
  34. package/dist/connection/contracts/IConnectionOptions.js +3 -0
  35. package/dist/connection/contracts/IConnectionOptions.js.map +1 -0
  36. package/dist/connection/contracts/IConnectionProvider.d.ts +6 -0
  37. package/dist/connection/contracts/IConnectionProvider.js +3 -0
  38. package/dist/connection/contracts/IConnectionProvider.js.map +1 -0
  39. package/dist/connection/contracts/IThriftConnection.d.ts +4 -0
  40. package/dist/connection/contracts/IThriftConnection.js +3 -0
  41. package/dist/connection/contracts/IThriftConnection.js.map +1 -0
  42. package/dist/connection/contracts/ITransport.d.ts +13 -0
  43. package/dist/connection/contracts/ITransport.js +3 -0
  44. package/dist/connection/contracts/ITransport.js.map +1 -0
  45. package/dist/connection/transports/HttpTransport.d.ts +14 -0
  46. package/dist/connection/transports/HttpTransport.js +39 -0
  47. package/dist/connection/transports/HttpTransport.js.map +1 -0
  48. package/dist/connection/types/AuthOptions.d.ts +4 -0
  49. package/dist/connection/types/AuthOptions.js +3 -0
  50. package/dist/connection/types/AuthOptions.js.map +1 -0
  51. package/dist/contracts/IHiveClient.d.ts +10 -0
  52. package/dist/contracts/IHiveClient.js +3 -0
  53. package/dist/contracts/IHiveClient.js.map +1 -0
  54. package/dist/contracts/IHiveSession.d.ts +126 -0
  55. package/dist/contracts/IHiveSession.js +3 -0
  56. package/dist/contracts/IHiveSession.js.map +1 -0
  57. package/dist/contracts/IOperation.d.ts +47 -0
  58. package/dist/contracts/IOperation.js +3 -0
  59. package/dist/contracts/IOperation.js.map +1 -0
  60. package/dist/dto/InfoValue.d.ts +9 -0
  61. package/dist/dto/InfoValue.js +31 -0
  62. package/dist/dto/InfoValue.js.map +1 -0
  63. package/dist/dto/Status.d.ts +15 -0
  64. package/dist/dto/Status.js +21 -0
  65. package/dist/dto/Status.js.map +1 -0
  66. package/dist/errors/AuthenticationError.d.ts +3 -0
  67. package/dist/errors/AuthenticationError.js +30 -0
  68. package/dist/errors/AuthenticationError.js.map +1 -0
  69. package/dist/errors/HiveDriverError.d.ts +2 -0
  70. package/dist/errors/HiveDriverError.js +26 -0
  71. package/dist/errors/HiveDriverError.js.map +1 -0
  72. package/dist/errors/OperationStateError.d.ts +6 -0
  73. package/dist/errors/OperationStateError.js +32 -0
  74. package/dist/errors/OperationStateError.js.map +1 -0
  75. package/dist/errors/StatusError.d.ts +8 -0
  76. package/dist/errors/StatusError.js +15 -0
  77. package/dist/errors/StatusError.js.map +1 -0
  78. package/dist/factory/StatusFactory.d.ts +14 -0
  79. package/dist/factory/StatusFactory.js +40 -0
  80. package/dist/factory/StatusFactory.js.map +1 -0
  81. package/dist/hive/Commands/BaseCommand.d.ts +7 -0
  82. package/dist/hive/Commands/BaseCommand.js +36 -0
  83. package/dist/hive/Commands/BaseCommand.js.map +1 -0
  84. package/dist/hive/Commands/CancelDelegationTokenCommand.d.ts +12 -0
  85. package/dist/hive/Commands/CancelDelegationTokenCommand.js +34 -0
  86. package/dist/hive/Commands/CancelDelegationTokenCommand.js.map +1 -0
  87. package/dist/hive/Commands/CancelOperationCommand.d.ts +11 -0
  88. package/dist/hive/Commands/CancelOperationCommand.js +34 -0
  89. package/dist/hive/Commands/CancelOperationCommand.js.map +1 -0
  90. package/dist/hive/Commands/CloseOperationCommand.d.ts +11 -0
  91. package/dist/hive/Commands/CloseOperationCommand.js +34 -0
  92. package/dist/hive/Commands/CloseOperationCommand.js.map +1 -0
  93. package/dist/hive/Commands/CloseSessionCommand.d.ts +11 -0
  94. package/dist/hive/Commands/CloseSessionCommand.js +34 -0
  95. package/dist/hive/Commands/CloseSessionCommand.js.map +1 -0
  96. package/dist/hive/Commands/ExecuteStatementCommand.d.ts +17 -0
  97. package/dist/hive/Commands/ExecuteStatementCommand.js +34 -0
  98. package/dist/hive/Commands/ExecuteStatementCommand.js.map +1 -0
  99. package/dist/hive/Commands/FetchResultsCommand.d.ts +20 -0
  100. package/dist/hive/Commands/FetchResultsCommand.js +34 -0
  101. package/dist/hive/Commands/FetchResultsCommand.js.map +1 -0
  102. package/dist/hive/Commands/GetCatalogsCommand.d.ts +12 -0
  103. package/dist/hive/Commands/GetCatalogsCommand.js +34 -0
  104. package/dist/hive/Commands/GetCatalogsCommand.js.map +1 -0
  105. package/dist/hive/Commands/GetColumnsCommand.d.ts +16 -0
  106. package/dist/hive/Commands/GetColumnsCommand.js +34 -0
  107. package/dist/hive/Commands/GetColumnsCommand.js.map +1 -0
  108. package/dist/hive/Commands/GetCrossReferenceCommand.d.ts +18 -0
  109. package/dist/hive/Commands/GetCrossReferenceCommand.js +34 -0
  110. package/dist/hive/Commands/GetCrossReferenceCommand.js.map +1 -0
  111. package/dist/hive/Commands/GetDelegationTokenCommand.d.ts +14 -0
  112. package/dist/hive/Commands/GetDelegationTokenCommand.js +34 -0
  113. package/dist/hive/Commands/GetDelegationTokenCommand.js.map +1 -0
  114. package/dist/hive/Commands/GetFunctionsCommand.d.ts +15 -0
  115. package/dist/hive/Commands/GetFunctionsCommand.js +34 -0
  116. package/dist/hive/Commands/GetFunctionsCommand.js.map +1 -0
  117. package/dist/hive/Commands/GetInfoCommand.d.ts +16 -0
  118. package/dist/hive/Commands/GetInfoCommand.js +34 -0
  119. package/dist/hive/Commands/GetInfoCommand.js.map +1 -0
  120. package/dist/hive/Commands/GetOperationStatusCommand.d.ts +23 -0
  121. package/dist/hive/Commands/GetOperationStatusCommand.js +34 -0
  122. package/dist/hive/Commands/GetOperationStatusCommand.js.map +1 -0
  123. package/dist/hive/Commands/GetPrimaryKeysCommand.d.ts +15 -0
  124. package/dist/hive/Commands/GetPrimaryKeysCommand.js +34 -0
  125. package/dist/hive/Commands/GetPrimaryKeysCommand.js.map +1 -0
  126. package/dist/hive/Commands/GetQueryIdCommand.d.ts +11 -0
  127. package/dist/hive/Commands/GetQueryIdCommand.js +34 -0
  128. package/dist/hive/Commands/GetQueryIdCommand.js.map +1 -0
  129. package/dist/hive/Commands/GetResultSetMetadataCommand.d.ts +12 -0
  130. package/dist/hive/Commands/GetResultSetMetadataCommand.js +34 -0
  131. package/dist/hive/Commands/GetResultSetMetadataCommand.js.map +1 -0
  132. package/dist/hive/Commands/GetSchemasCommand.d.ts +14 -0
  133. package/dist/hive/Commands/GetSchemasCommand.js +34 -0
  134. package/dist/hive/Commands/GetSchemasCommand.js.map +1 -0
  135. package/dist/hive/Commands/GetTableTypesCommand.d.ts +12 -0
  136. package/dist/hive/Commands/GetTableTypesCommand.js +34 -0
  137. package/dist/hive/Commands/GetTableTypesCommand.js.map +1 -0
  138. package/dist/hive/Commands/GetTablesCommand.d.ts +16 -0
  139. package/dist/hive/Commands/GetTablesCommand.js +34 -0
  140. package/dist/hive/Commands/GetTablesCommand.js.map +1 -0
  141. package/dist/hive/Commands/GetTypeInfoCommand.d.ts +12 -0
  142. package/dist/hive/Commands/GetTypeInfoCommand.js +34 -0
  143. package/dist/hive/Commands/GetTypeInfoCommand.js.map +1 -0
  144. package/dist/hive/Commands/OpenSessionCommand.d.ts +33 -0
  145. package/dist/hive/Commands/OpenSessionCommand.js +34 -0
  146. package/dist/hive/Commands/OpenSessionCommand.js.map +1 -0
  147. package/dist/hive/Commands/RenewDelegationTokenCommand.d.ts +12 -0
  148. package/dist/hive/Commands/RenewDelegationTokenCommand.js +34 -0
  149. package/dist/hive/Commands/RenewDelegationTokenCommand.js.map +1 -0
  150. package/dist/hive/Commands/SetClientInfoCommand.d.ts +12 -0
  151. package/dist/hive/Commands/SetClientInfoCommand.js +34 -0
  152. package/dist/hive/Commands/SetClientInfoCommand.js.map +1 -0
  153. package/dist/hive/HiveDriver.d.ts +52 -0
  154. package/dist/hive/HiveDriver.js +129 -0
  155. package/dist/hive/HiveDriver.js.map +1 -0
  156. package/dist/hive/Types/index.d.ts +229 -0
  157. package/dist/hive/Types/index.js +16 -0
  158. package/dist/hive/Types/index.js.map +1 -0
  159. package/dist/index.d.ts +25 -0
  160. package/dist/index.js +67 -0
  161. package/dist/index.js.map +1 -0
  162. package/dist/result/IOperationResult.d.ts +5 -0
  163. package/dist/result/IOperationResult.js +3 -0
  164. package/dist/result/IOperationResult.js.map +1 -0
  165. package/dist/result/JsonResult.d.ts +20 -0
  166. package/dist/result/JsonResult.js +137 -0
  167. package/dist/result/JsonResult.js.map +1 -0
  168. package/dist/result/NullResult.d.ts +6 -0
  169. package/dist/result/NullResult.js +13 -0
  170. package/dist/result/NullResult.js.map +1 -0
  171. package/dist/utils/GetResult.d.ts +16 -0
  172. package/dist/utils/GetResult.js +38 -0
  173. package/dist/utils/GetResult.js.map +1 -0
  174. package/dist/utils/HiveUtils.d.ts +11 -0
  175. package/dist/utils/HiveUtils.js +39 -0
  176. package/dist/utils/HiveUtils.js.map +1 -0
  177. package/dist/utils/ProgressUpdateTransformer.d.ts +8 -0
  178. package/dist/utils/ProgressUpdateTransformer.js +33 -0
  179. package/dist/utils/ProgressUpdateTransformer.js.map +1 -0
  180. package/dist/utils/WaitUntilReady.d.ts +16 -0
  181. package/dist/utils/WaitUntilReady.js +120 -0
  182. package/dist/utils/WaitUntilReady.js.map +1 -0
  183. package/docs/readme.md +227 -0
  184. package/docs/troubleshooting.md +84 -0
  185. package/examples/data_types.js +173 -0
  186. package/examples/repl +106 -0
  187. package/examples/session.js +55 -0
  188. package/examples/usage.js +18 -0
  189. package/nyc.config.js +8 -0
  190. package/package.json +56 -0
  191. package/tests/e2e/data_types.test.js +353 -0
  192. package/tests/e2e/utils/config.js +20 -0
  193. package/tests/e2e/utils/logger.js +22 -0
  194. package/tests/unit/HiveClient.test.js +153 -0
  195. package/tests/unit/HiveOperation.test.js +340 -0
  196. package/tests/unit/HiveSession.test.js +146 -0
  197. package/tests/unit/connection/auth/PlainHttpAuthentication.test.js +44 -0
  198. package/tests/unit/connection/connections/HttpConnection.test.js +141 -0
  199. package/tests/unit/dto/InfoValue.test.js +50 -0
  200. package/tests/unit/factory/StatusFactory.test.js +62 -0
  201. package/tests/unit/hive/HiveDriver.test.js +115 -0
  202. package/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js +43 -0
  203. package/tests/unit/hive/commands/CancelOperationCommand.test.js +45 -0
  204. package/tests/unit/hive/commands/CloseOperationCommand.test.js +45 -0
  205. package/tests/unit/hive/commands/CloseSessionCommand.test.js +38 -0
  206. package/tests/unit/hive/commands/ExecuteStatementCommand.test.js +54 -0
  207. package/tests/unit/hive/commands/FetchResultsCommand.test.js +59 -0
  208. package/tests/unit/hive/commands/GetCatalogsCommand.test.js +50 -0
  209. package/tests/unit/hive/commands/GetColumnsCommand.test.js +50 -0
  210. package/tests/unit/hive/commands/GetCrossReferenceCommand.test.js +56 -0
  211. package/tests/unit/hive/commands/GetDelegationTokenCommand.test.js +45 -0
  212. package/tests/unit/hive/commands/GetFunctionsCommand.test.js +50 -0
  213. package/tests/unit/hive/commands/GetInfoCommand.test.js +51 -0
  214. package/tests/unit/hive/commands/GetOperationStatusCommand.test.js +63 -0
  215. package/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js +50 -0
  216. package/tests/unit/hive/commands/GetQueryIdCommand.test.js +42 -0
  217. package/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js +54 -0
  218. package/tests/unit/hive/commands/GetSchemasCommand.test.js +52 -0
  219. package/tests/unit/hive/commands/GetTableTypesCommand.test.js +50 -0
  220. package/tests/unit/hive/commands/GetTablesCommand.test.js +54 -0
  221. package/tests/unit/hive/commands/GetTypeInfoCommand.test.js +50 -0
  222. package/tests/unit/hive/commands/OpenSessionCommand.test.js +43 -0
  223. package/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js +43 -0
  224. package/tests/unit/hive/commands/SetClientInfoCommand.test.js +45 -0
  225. package/tests/unit/result/JsonResult.test.js +295 -0
  226. package/tests/unit/utils/GetResult.test.js +30 -0
  227. package/tests/unit/utils/HiveUtils.test.js +60 -0
  228. package/tests/unit/utils/ProgressUpdateTransformer.test.js +28 -0
  229. package/tests/unit/utils/WaitUntilReady.test.js +105 -0
  230. package/thrift/TCLIService.thrift +1299 -0
  231. package/thrift/gen-nodejs/TCLIService.js +4596 -0
  232. package/thrift/gen-nodejs/TCLIService_types.js +6794 -0
  233. package/tsconfig.json +13 -0
package/.gitattributes ADDED
@@ -0,0 +1,32 @@
1
+ # Set the default behavior, in case users don't have core.autocrlf set
2
+ * text=auto
3
+
4
+ # Files that should always be normalized and converted to native line
5
+ # endings on checkout.
6
+
7
+ *.js text
8
+ *.json text
9
+ *.yml text
10
+ *.xml text
11
+ *.ts text
12
+ *.md text
13
+ *.sh text eol=lf
14
+ *.conf text
15
+ *.thrift text
16
+ *.properties text
17
+ LICENSE text
18
+ Makefile text
19
+ Dockerfile* text
20
+
21
+ # Files that are truly binary and should not be modified
22
+ *.pem binary
23
+ *.crt binary
24
+ *.key binary
25
+ *.jks binary
26
+ *.p12 binary
27
+
28
+ # Exclude files from exporting
29
+ #
30
+
31
+ .gitattributes export-ignore
32
+ .gitignore export-ignore
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # Changelog
@@ -0,0 +1,55 @@
1
+ # Contributing
2
+
3
+ To contribute to this repository fork it and send pull request.
4
+
5
+ ## Project structure
6
+
7
+ - *lib/* - source code written on TypeScript
8
+ - *dist/* - compiled source code and must not be changed manually
9
+ - *tests/unit/* - unit tests
10
+ - *tests/e2e/* - end-to-end tests
11
+ - *index.js* - entry point of the driver
12
+
13
+ ## Run the project
14
+
15
+ Hot compiling of TypeScript
16
+
17
+ ```bash
18
+ npm run watch
19
+ ```
20
+
21
+ Build the project
22
+
23
+ ```bash
24
+ npm run build
25
+ ```
26
+
27
+ Tests:
28
+
29
+ ```bash
30
+ npm run test
31
+
32
+ npm run e2e
33
+ ```
34
+
35
+ ## Commit messages
36
+
37
+ Please follow the [Angular commit style][angular-commit-style].
38
+
39
+ To make it easy, just run the command
40
+
41
+ ```bash
42
+ npm run commit
43
+ ```
44
+
45
+ ## Pull Request Process
46
+
47
+ 1. Update the README.md or similar documentation with details of changes you
48
+ wish to make, if applicable.
49
+ 2. Add any appropriate tests.
50
+ 3. Make your code or other changes.
51
+ 4. Review guidelines such as
52
+ [How to write the perfect pull request][github-perfect-pr], thanks!
53
+
54
+ [angular-commit-style]: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits
55
+ [github-perfect-pr]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2022 Databricks, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Databricks SQL Node.js Driver (Beta)
2
+
3
+ ## Description
4
+
5
+ Databricks SQL Driver is a JavaScript driver for connection to [Databricks SQL](https://databricks.com/product/databricks-sql) and issue SQL queries.
6
+
7
+ **NOTE: This Driver is Beta.**
8
+
9
+ ## Requirements
10
+
11
+ - Node.js 14 or newer
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm i @databricks/sql
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ [examples/usage.js](examples/usage.js)
22
+ ```javascript
23
+ const { DBSQLClient } = require('@databricks/sql');
24
+
25
+ const client = new DBSQLClient();
26
+ const utils = DBSQLClient.utils;
27
+
28
+ client.connect({
29
+ host: '********.databricks.com',
30
+ path: '/sql/1.0/endpoints/****************',
31
+ token: 'dapi********************************',
32
+ }).then(async client => {
33
+ const session = await client.openSession();
34
+
35
+ const queryOperation = await session.executeStatement('SELECT "Hello, World!"', { runAsync: true });
36
+ await utils.waitUntilReady(queryOperation, false, () => {});
37
+ await utils.fetchAll(queryOperation);
38
+ await queryOperation.close();
39
+
40
+ const result = utils.getResult(queryOperation).getValue();
41
+ console.table(result);
42
+
43
+ await session.close();
44
+ await client.close();
45
+ }).catch(error => {
46
+ console.log(error);
47
+ });
48
+ ```
49
+
50
+ For more details see: [Getting Started](docs/readme.md)
51
+
52
+ ## Test
53
+
54
+ Unit tests:
55
+
56
+ ```bash
57
+ npm run test
58
+ ```
59
+
60
+ e2e tests:
61
+
62
+ ```bash
63
+ npm run e2e
64
+ ```
65
+
66
+ Before running e2e tests, create local [configuration file](tests/e2e/utils/config.js)
67
+
68
+ ## Contributing
69
+
70
+ See [CONTRIBUTING.md](CONTRIBUTING.md)
71
+
72
+ ## Issues
73
+
74
+ If you find some issues, feel free to create an issue or send a pull request.
75
+
76
+ ## License
77
+
78
+ [Apache License 2.0](LICENSE)
@@ -0,0 +1,42 @@
1
+ /// <reference types="node" />
2
+ import HiveUtils from "./utils/HiveUtils";
3
+ import IHiveSession from "./contracts/IHiveSession";
4
+ interface EventEmitter extends NodeJS.EventEmitter {
5
+ }
6
+ interface IConnectionOptions {
7
+ host: string;
8
+ port?: number;
9
+ path: string;
10
+ token: string;
11
+ }
12
+ /**
13
+ * @see IHiveClient
14
+ */
15
+ interface IDBSQLClient {
16
+ connect(options: IConnectionOptions): Promise<IDBSQLClient>;
17
+ openSession(): Promise<IHiveSession>;
18
+ close(): void;
19
+ }
20
+ export default class DBSQLClient implements IDBSQLClient, EventEmitter {
21
+ static utils: HiveUtils;
22
+ private client;
23
+ connect(options: IConnectionOptions): Promise<this>;
24
+ openSession(): Promise<IHiveSession>;
25
+ close(): void;
26
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
27
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
28
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
29
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
30
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
31
+ removeAllListeners(event?: string | symbol): this;
32
+ setMaxListeners(n: number): this;
33
+ getMaxListeners(): number;
34
+ listeners(event: string | symbol): Function[];
35
+ rawListeners(event: string | symbol): Function[];
36
+ emit(event: string | symbol, ...args: any[]): boolean;
37
+ listenerCount(type: string | symbol): number;
38
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
39
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
40
+ eventNames(): (string | symbol)[];
41
+ }
42
+ export {};
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ var TCLIService = require('../thrift/gen-nodejs/TCLIService');
16
+ var TCLIService_types = require('../thrift/gen-nodejs/TCLIService_types');
17
+ var HiveClient_1 = __importDefault(require("./HiveClient"));
18
+ var HiveUtils_1 = __importDefault(require("./utils/HiveUtils"));
19
+ var PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/PlainHttpAuthentication"));
20
+ var HttpConnection_1 = __importDefault(require("./connection/connections/HttpConnection"));
21
+ var DBSQLClient = /** @class */ (function () {
22
+ function DBSQLClient() {
23
+ this.client = new HiveClient_1.default(TCLIService, TCLIService_types);
24
+ }
25
+ DBSQLClient.prototype.connect = function (options) {
26
+ var _this = this;
27
+ return this.client.connect({
28
+ host: options.host,
29
+ port: options.port || 443,
30
+ options: {
31
+ path: options.path,
32
+ https: true,
33
+ }
34
+ }, new HttpConnection_1.default(), new PlainHttpAuthentication_1.default({
35
+ username: 'token',
36
+ password: options.token,
37
+ })).then(function () { return _this; });
38
+ };
39
+ DBSQLClient.prototype.openSession = function () {
40
+ return this.client.openSession({
41
+ client_protocol: TCLIService_types.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11
42
+ });
43
+ };
44
+ DBSQLClient.prototype.close = function () {
45
+ this.client.close();
46
+ };
47
+ // EventEmitter
48
+ DBSQLClient.prototype.addListener = function (event, listener) {
49
+ this.client.addListener(event, listener);
50
+ return this;
51
+ };
52
+ DBSQLClient.prototype.on = function (event, listener) {
53
+ this.client.on(event, listener);
54
+ return this;
55
+ };
56
+ DBSQLClient.prototype.once = function (event, listener) {
57
+ this.client.once(event, listener);
58
+ return this;
59
+ };
60
+ DBSQLClient.prototype.removeListener = function (event, listener) {
61
+ this.client.removeListener(event, listener);
62
+ return this;
63
+ };
64
+ DBSQLClient.prototype.off = function (event, listener) {
65
+ this.client.off(event, listener);
66
+ return this;
67
+ };
68
+ DBSQLClient.prototype.removeAllListeners = function (event) {
69
+ this.client.removeAllListeners(event);
70
+ return this;
71
+ };
72
+ DBSQLClient.prototype.setMaxListeners = function (n) {
73
+ this.client.setMaxListeners(n);
74
+ return this;
75
+ };
76
+ DBSQLClient.prototype.getMaxListeners = function () {
77
+ return this.client.getMaxListeners();
78
+ };
79
+ DBSQLClient.prototype.listeners = function (event) {
80
+ return this.client.listeners(event);
81
+ };
82
+ DBSQLClient.prototype.rawListeners = function (event) {
83
+ return this.client.rawListeners(event);
84
+ };
85
+ DBSQLClient.prototype.emit = function (event) {
86
+ var _a;
87
+ var args = [];
88
+ for (var _i = 1; _i < arguments.length; _i++) {
89
+ args[_i - 1] = arguments[_i];
90
+ }
91
+ return (_a = this.client).emit.apply(_a, __spreadArray([event], args, false));
92
+ };
93
+ DBSQLClient.prototype.listenerCount = function (type) {
94
+ return this.client.listenerCount(type);
95
+ };
96
+ DBSQLClient.prototype.prependListener = function (event, listener) {
97
+ this.client.prependListener(event, listener);
98
+ return this;
99
+ };
100
+ DBSQLClient.prototype.prependOnceListener = function (event, listener) {
101
+ this.client.prependOnceListener(event, listener);
102
+ return this;
103
+ };
104
+ DBSQLClient.prototype.eventNames = function () {
105
+ return this.client.eventNames();
106
+ };
107
+ DBSQLClient.utils = new HiveUtils_1.default(TCLIService_types);
108
+ return DBSQLClient;
109
+ }());
110
+ exports.default = DBSQLClient;
111
+ //# sourceMappingURL=DBSQLClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DBSQLClient.js","sourceRoot":"","sources":["../lib/DBSQLClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,IAAM,WAAW,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAChE,IAAM,i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;IACD,mCAAa,GAAb,UAAc,IAAqB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD,qCAAe,GAAf,UAAgB,KAAsB,EAAE,QAAkC;QACtE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,yCAAmB,GAAnB,UAAoB,KAAsB,EAAE,QAAkC;QAC1E,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,gCAAU,GAAV;QACI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAtFM,iBAAK,GAAG,IAAI,mBAAS,CAAC,iBAAiB,CAAC,CAAC;IAuFpD,kBAAC;CAAA,AAxFD,IAwFC;kBAxFoB,WAAW"}
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import { ThriftClient, TCLIServiceTypes } from './hive/Types/';
3
+ import IHiveClient from './contracts/IHiveClient';
4
+ import { OpenSessionRequest } from './hive/Commands/OpenSessionCommand';
5
+ import IHiveSession from './contracts/IHiveSession';
6
+ import IConnectionProvider from './connection/contracts/IConnectionProvider';
7
+ import IAuthentication from './connection/contracts/IAuthentication';
8
+ import IConnectionOptions from './connection/contracts/IConnectionOptions';
9
+ import { EventEmitter } from 'events';
10
+ export default class HiveClient extends EventEmitter implements IHiveClient {
11
+ private TCLIService;
12
+ private TCLIService_types;
13
+ private client;
14
+ private connection;
15
+ private statusFactory;
16
+ private connectionProvider;
17
+ private authProvider;
18
+ private thrift;
19
+ /**
20
+ *
21
+ * @param TCLIService generated from TCLIService.thrift (https://github.com/apache/hive/blob/master/service-rpc/if/TCLIService.thrift)
22
+ * @param TCLIService_types object generated from TCLIService.thrift
23
+ */
24
+ constructor(TCLIService: object, TCLIService_types: TCLIServiceTypes);
25
+ connect(options: IConnectionOptions, connectionProvider?: IConnectionProvider, authProvider?: IAuthentication): Promise<HiveClient>;
26
+ /**
27
+ * Starts new session
28
+ *
29
+ * @param request
30
+ * @throws {StatusError}
31
+ */
32
+ openSession(request: OpenSessionRequest): Promise<IHiveSession>;
33
+ getClient(): ThriftClient;
34
+ close(): void;
35
+ }