AMBARI-20901. Improvement needed for creating ACID tables. (dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bfcc42dc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bfcc42dc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bfcc42dc Branch: refs/heads/branch-feature-AMBARI-12556 Commit: bfcc42dcc76aabe9e00c123b92ea9d40d643c713 Parents: 9eddcc2 Author: Dipayan Bhowmick <dipayan.bhowm...@gmail.com> Authored: Mon May 1 14:37:45 2017 +0530 Committer: Dipayan Bhowmick <dipayan.bhowm...@gmail.com> Committed: Mon May 1 14:38:30 2017 +0530 ---------------------------------------------------------------------- .../resources/ui/app/components/create-table.js | 32 +++++++++++++++----- .../app/templates/components/create-table.hbs | 4 +-- .../ui/app/templates/components/edit-table.hbs | 5 --- 3 files changed, 26 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/bfcc42dc/contrib/views/hive20/src/main/resources/ui/app/components/create-table.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/create-table.js b/contrib/views/hive20/src/main/resources/ui/app/components/create-table.js index 322aab5..1e8e673 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/components/create-table.js +++ b/contrib/views/hive20/src/main/resources/ui/app/components/create-table.js @@ -66,7 +66,8 @@ export default Ember.Component.extend({ } if (!(this.checkColumnsExists() && this.checkColumnUniqueness() && - this.validateColumns())) { + this.validateColumns() && + this.checkClusteringIfTransactional())) { this.selectTab("create.table.columns"); return false; } @@ -96,11 +97,11 @@ export default Ember.Component.extend({ }, checkColumnsExists() { - this.set('hasEmptyColumnsError'); - this.set('emptyColumnsErrorText'); + this.set('hasTableConfigurationError'); + this.set('tableConfigurationErrorText'); if (this.get('columns.length') === 0) { - this.set('hasEmptyColumnsError', true); - this.set('emptyColumnsErrorText', 'No columns configured. Add some column definitions.'); + this.set('hasTableConfigurationError', true); + this.set('tableConfigurationErrorText', 'No columns configured. Add some column definitions.'); return false; } return true; @@ -132,6 +133,16 @@ export default Ember.Component.extend({ return true; }, + checkClusteringIfTransactional() { + let clusteredColumns = this.get('columns').filterBy('isClustered', true); + if (this.get('settings.transactional') && clusteredColumns.get('length') === 0) { + this.set('hasTableConfigurationError', true); + this.set('tableConfigurationErrorText', 'Table is marked as transactional but no clustered column defined. Add some clustered column definitions.'); + return false; + } + return true; + }, + validateTableProperties() { for (let i = 0; i < this.get('properties.length'); i++) { let property = this.get('properties').objectAt(i); @@ -144,9 +155,14 @@ export default Ember.Component.extend({ validateNumBuckets() { let clusteredColumns = this.get('columns').filterBy('isClustered', true); - if(clusteredColumns.get('length') > 0 && - (Ember.isEmpty(this.get('settings.numBuckets')) || - !Helper.isInteger(this.get('settings.numBuckets')))) { + + + function isNumBucketsPresentAndIsAnInteger(context) { + return (Ember.isEmpty(context.get('settings.numBuckets')) || + !Helper.isInteger(context.get('settings.numBuckets'))); + } + + if(clusteredColumns.get('length') > 0 && isNumBucketsPresentAndIsAnInteger(this)) { this.get('settingErrors').pushObject({type: 'numBuckets', error: "Some columns are clustered, Number of buckets are required."}); return false; } http://git-wip-us.apache.org/repos/asf/ambari/blob/bfcc42dc/contrib/views/hive20/src/main/resources/ui/app/templates/components/create-table.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/create-table.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/components/create-table.hbs index 2ffbd2a..80e05de 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/templates/components/create-table.hbs +++ b/contrib/views/hive20/src/main/resources/ui/app/templates/components/create-table.hbs @@ -39,9 +39,9 @@ {{#each tabs as |tab|}} {{#if tab.active}} {{#if (eq tab.link "create.table.columns")}} - {{#if hasEmptyColumnsError}} + {{#if hasTableConfigurationError}} <div class="alert alert-danger create-table-error"> - {{emptyColumnsErrorText}} + {{tableConfigurationErrorText}} </div> {{/if}} {{table-columns columns=columns shouldAddBuckets=shouldAddBuckets options=options}} http://git-wip-us.apache.org/repos/asf/ambari/blob/bfcc42dc/contrib/views/hive20/src/main/resources/ui/app/templates/components/edit-table.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/edit-table.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/components/edit-table.hbs index 7a02d3a..25048e7 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/templates/components/edit-table.hbs +++ b/contrib/views/hive20/src/main/resources/ui/app/templates/components/edit-table.hbs @@ -26,11 +26,6 @@ {{#each tabs as |tab|}} {{#if tab.active}} {{#if (eq tab.link "edit.table.columns")}} - {{#if hasEmptyColumnsError}} - <div class="alert alert-danger create-table-error"> - {{emptyColumnsErrorText}} - </div> - {{/if}} {{table-columns columns=columns shouldAddBuckets=shouldAddBuckets editMode=true}} {{/if}} {{#if (eq tab.link "edit.table.properties")}}