Explorar el Código

[core] Add 'show' snippets to the Hive autocomplete

Added alphabetic sorting and precedence to keywords too
Enrico Berti hace 10 años
padre
commit
94f95105fa

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ace.js


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ext-language_tools.js


+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ace/snippets/hive.js

@@ -1 +1 @@
-ace.define("ace/snippets/hive",["require","exports","module"],function(e,t,n){"use strict";t.snippetText="snippet tbl\n	create table ${1:table} (\n		${2:columns}\n	);\nsnippet s*\n	select * from ${1:table}\n",t.scope="hive"})
+ace.define("ace/snippets/hive",["require","exports","module"],function(e,t,n){"use strict";t.snippetText="snippet tbl\n	create table ${1:table_name} (\n		${2:columns}\n	);\nsnippet s*\n	select * from ${1:table_name}\nsnippet showcolumns\n	SHOW COLUMNS (FROM|IN) table_name [(FROM|IN) db_name];\nsnippet showcompactions\n	SHOW COMPACTIONS;\nsnippet showconf\n	SHOW CONF <configuration_name>;\nsnippet showcreate\n	SHOW CREATE TABLE ([db_name.]table_name|view_name);\nsnippet showcurrentroles\n	SHOW CURRENT ROLES;\nsnippet showdatabases\n	SHOW (DATABASES|SCHEMAS) [LIKE 'identifier_with_wildcards'];\nsnippet showdblocks\n	SHOW LOCKS (DATABASE|SCHEMA) database_name;\nsnippet showfunctions\n	SHOW FUNCTIONS \"a.*\";\nsnippet showgrant\n	SHOW GRANT;\nsnippet showindex\n	SHOW [FORMATTED] (INDEX|INDEXES) ON ${1:table_with_index} [(FROM|IN) ${2:db_name}];\nsnippet showlocks\n	SHOW LOCKS ${1:table_name} PARTITION (${2:partition_spec}) EXTENDED;\nsnippet showpartitions\n	SHOW PARTITIONS ${1:table_name} PARTITION(ds='2010-03-03', hr='12');\nsnippet showprincipals\n	SHOW PRINCIPALS;\nsnippet showrolegrant\n	SHOW ROLE GRANT;\nsnippet showroles\n	SHOW ROLES;\nsnippet showtableextended\n	SHOW TABLE EXTENDED [IN|FROM ${1:database_name}] LIKE 'identifier_with_wildcards' [PARTITION(${2:partition_spec})];\nsnippet showtables\n	SHOW TABLES [IN ${1:database_name}] ['identifier_with_wildcards'];\nsnippet showtblproperties\n	SHOW TBLPROPERTIES ${1:table_name};\nsnippet showtransactions\n	SHOW TRANSACTIONS;\n",t.scope="hive"})

+ 9 - 2
tools/ace-editor/lib/ace/autocomplete.js

@@ -433,8 +433,15 @@ var FilteredList = function(array, filterText) {
 
         this.filterText = str;
         matches = this.filterCompletions(matches, this.filterText);
-        matches = matches.sort(function(a, b) {
-            return b.exactMatch - a.exactMatch || b.score - a.score;
+        matches = matches.sort(function (a, b) {
+          var alpha = 0;
+          if (a.caption > b.caption) {
+            alpha = 1;
+          }
+          if (a.caption < b.caption) {
+            alpha = -1;
+          }
+          return alpha + b.exactMatch - a.exactMatch || alpha + b.score - a.score;
         });
 
         // make unique

+ 1 - 1
tools/ace-editor/lib/ace/mode/text.js

@@ -373,7 +373,7 @@ var Mode = function() {
             return {
                 name: word,
                 value: word,
-                score: 0,
+                score: 1,
                 meta: "keyword"
             };
         });

+ 40 - 2
tools/ace-editor/lib/ace/snippets/hive.snippets

@@ -1,6 +1,44 @@
 snippet tbl
-	create table ${1:table} (
+	create table ${1:table_name} (
 		${2:columns}
 	);
 snippet s*
-	select * from ${1:table}
+	select * from ${1:table_name}
+snippet showcolumns
+	SHOW COLUMNS (FROM|IN) table_name [(FROM|IN) db_name];
+snippet showcompactions
+	SHOW COMPACTIONS;
+snippet showconf
+	SHOW CONF <configuration_name>;
+snippet showcreate
+	SHOW CREATE TABLE ([db_name.]table_name|view_name);
+snippet showcurrentroles
+	SHOW CURRENT ROLES;
+snippet showdatabases
+	SHOW (DATABASES|SCHEMAS) [LIKE 'identifier_with_wildcards'];
+snippet showdblocks
+	SHOW LOCKS (DATABASE|SCHEMA) database_name;
+snippet showfunctions
+	SHOW FUNCTIONS "a.*";
+snippet showgrant
+	SHOW GRANT;
+snippet showindex
+	SHOW [FORMATTED] (INDEX|INDEXES) ON ${1:table_with_index} [(FROM|IN) ${2:db_name}];
+snippet showlocks
+	SHOW LOCKS ${1:table_name} PARTITION (${2:partition_spec}) EXTENDED;
+snippet showpartitions
+	SHOW PARTITIONS ${1:table_name} PARTITION(ds='2010-03-03', hr='12');
+snippet showprincipals
+	SHOW PRINCIPALS;
+snippet showrolegrant
+	SHOW ROLE GRANT;
+snippet showroles
+	SHOW ROLES;
+snippet showtableextended
+	SHOW TABLE EXTENDED [IN|FROM ${1:database_name}] LIKE 'identifier_with_wildcards' [PARTITION(${2:partition_spec})];
+snippet showtables
+	SHOW TABLES [IN ${1:database_name}] ['identifier_with_wildcards'];
+snippet showtblproperties
+	SHOW TBLPROPERTIES ${1:table_name};
+snippet showtransactions
+	SHOW TRANSACTIONS;

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio