Skip to content

Commit

Permalink
[importer_direct_upload] solving the issue of snippet_type and connec…
Browse files Browse the repository at this point in the history
…tor_type conflict
  • Loading branch information
agl29 committed May 15, 2021
1 parent ae5b51a commit a960815
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions desktop/libs/indexer/src/indexer/indexers/sql.py
Expand Up @@ -29,6 +29,7 @@

from azure.abfs.__init__ import abfspath
from hadoop.fs.hadoopfs import Hdfs
from notebook.connectors.base import get_interpreter
from notebook.models import make_notebook
from useradmin.models import User

Expand Down Expand Up @@ -295,9 +296,11 @@ def create_table_from_local_file(self, source, destination, start_time=-1):

columns = destination['columns']

if editor_type in ('hive', 'mysql'):
dialect = get_interpreter(source_type, self.user)['dialect']

if editor_type == 'mysql':
if dialect in ('hive', 'mysql'):

if dialect == 'mysql':
for col in columns:
if col['type'] == 'string':
col['type'] = 'VARCHAR(255)'
Expand All @@ -322,7 +325,7 @@ def create_table_from_local_file(self, source, destination, start_time=-1):

csv_rows = str(list_of_tuples)[1:-1]

if editor_type in ('hive', 'mysql'):
if dialect in ('hive', 'mysql'):
sql += '''\nINSERT INTO %(database)s.%(table_name)s VALUES %(csv_rows)s;
'''% {
'database': database,
Expand Down
2 changes: 1 addition & 1 deletion desktop/libs/indexer/src/indexer/templates/importer.mako
Expand Up @@ -552,7 +552,7 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
<!-- ko if: ['table', 'database'].indexOf(outputFormat()) != -1 -->
<div data-bind="visible: $parent.createWizard.source.inputFormat() == 'localfile'">
<label for="dialectType" class="control-label "><div>${ _('Dialect') }</div>
<select id="dialectType" data-bind="selectize: $parent.createWizard.source.interpreters, value: $parent.createWizard.source.interpreter, optionsText: 'name', optionsValue: 'dialect'"></select>
<select id="dialectType" data-bind="selectize: $parent.createWizard.source.interpreters, value: $parent.createWizard.source.interpreter, optionsText: 'name', optionsValue: 'type'"></select>
</label>
</div>
<label for="collectionName" class="control-label "><div>${ _('Name') }</div></label>
Expand Down

0 comments on commit a960815

Please sign in to comment.