Browse Source

HUE-3803 [hive] Support unicode in queries

Jenny Kim 9 years ago
parent
commit
4aee5e7

+ 1 - 5
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -18,11 +18,7 @@
 import copy
 import logging
 import re
-import sys
-if sys.version_info < (2, 7):
-  import StringIO
-else:
-  import cStringIO as StringIO
+import StringIO
 
 from django.core.urlresolvers import reverse
 from django.utils.translation import ugettext as _

+ 32 - 0
desktop/libs/notebook/src/notebook/connectors/tests/tests_hiveserver2.py

@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 # Licensed to Cloudera, Inc. under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -275,6 +276,37 @@ class TestHiveserver2ApiWithHadoop(BeeswaxSampleProvider):
       data=self.notebook_json)
 
 
+  def test_query_with_unicode(self):
+    statement = "SELECT * FROM sample_07 WHERE code='validé';"
+
+    snippet_json = json.loads("""
+        {
+            "status": "running",
+            "database": "default",
+            "id": "d70d31ee-a62a-4854-b2b1-b852f6a390f5",
+            "result": {
+                "type": "table",
+                "handle": {},
+                "id": "ca11fcb1-11a5-f534-8200-050c8e1e57e3"
+            },
+            "statement": "%(statement)s",
+            "type": "hive",
+            "properties": {
+                "files": [],
+                "functions": [],
+                "settings": []
+            }
+        }
+      """ % {'statement': statement})
+
+    notebook_json = json.loads(self.notebook_json)
+    notebook_json['snippets'] = [snippet_json]
+    response = self.client.post(reverse('notebook:execute'),
+                                {'notebook': json.dumps(notebook_json), 'snippet': json.dumps(snippet_json)})
+    data = json.loads(response.content)
+    assert_equal(0, data['status'], data)
+
+
   def test_get_current_statement(self):
     multi_statement = "SELECT description, salary FROM sample_07 LIMIT 20;\\r\\nSELECT AVG(salary) FROM sample_07;"
     snippet_json = json.loads("""