def update_column(self, column_name, new_name=None, new_type=None, new_description=None): self._check_column_exists(column_name) if new_name is None and new_type is None and new_description is None: raise ValueError( "one or more of the function inputs (new_name, new_type and new_description) must be specified." ) new_cols = [] for c in self.columns: if c['name'] == column_name: if new_name is not None: _validate_string(new_name, "_") c['name'] = new_name if new_type is not None: self._check_valid_datatype(new_type) c['type'] = new_type if new_description is not None: _validate_string(new_description, "_,.") c['description'] = new_description new_cols.append(c) self.columns = new_cols
def add_column(self, name, type, description): self._check_column_does_not_exists(name) self._check_valid_datatype(type) _validate_string(name) cols = self.columns cols.append({"name": name, "type": type, "description": description}) self.columns = cols
def location(self, location): _validate_string(location, allowed_chars="_/-") if location and location != '': if location[0] == '/': raise ValueError("location should not start with a slash") self._location = location else: raise ValueError( "Your table must exist inside a folder in S3. Please specify a location." )
def test_meta_funs(self): self.assertEqual(_end_with_slash('no_slash'), 'no_slash/') self.assertEqual(_end_with_slash('slash/'), 'slash/') self.assertRaises(ValueError, _validate_string, "UPPER") self.assertRaises(ValueError, _validate_string, "test:!@") self.assertEqual(_validate_string("test:!@", ":!@"), None) self.assertEqual(_remove_final_slash('hello/'), 'hello') self.assertEqual(_remove_final_slash('hello'), 'hello')
def test_meta_funs(self): self.assertEqual(_end_with_slash("no_slash"), "no_slash/") self.assertEqual(_end_with_slash("slash/"), "slash/") self.assertRaises(ValueError, _validate_string, "UPPER") self.assertRaises(ValueError, _validate_string, "test:!@") self.assertEqual(_validate_string("test:!@", ":!@"), None) self.assertEqual(_remove_final_slash("hello/"), "hello") self.assertEqual(_remove_final_slash("hello"), "hello")
def job_name(self, job_name): _validate_string(job_name, allowed_chars="-_:") self._job_name = job_name
def bucket(self, bucket): _validate_string(bucket, "-,") self._bucket = bucket
def bucket(self, bucket): _validate_string(bucket, '-,') self._bucket = bucket
def name(self, name): _validate_string(name) self._name = name
def bucket(self, bucket): _validate_string(bucket, allowed_chars='.-') self._bucket = bucket