def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() hive.data2table(filepath=options['path'], table=options['table'], overwrite=options['path'], # TODO partition=options['partition'])
def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() if options['path']: for path in (hive.check_for_content(options['path'], flags['r'])): grass.message(path)
def main(): conn = ConnectionManager() conn.get_current_connection(options["conn_type"]) hive = conn.get_hook() result = hive.execute(options['hql'], options['fatch']) if flags['f']: for i in result: print(i)
def main(): if not options['columns'] and not options['struct']: grass.fatal("Must be defined <attributes> or <struct> parameter") conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() hive.create_geom_table(table=options['table'], field=options['columns'], stored=options['stored'], serde=options['serde'], outputformat=options['outformat'], external=flags['e'], recreate=flags['d'], filepath=options['jsonpath'], overwrite=flags['o'])
def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() hive.create_csv_table(table=options['table'], field=options['columns'], partition=options['partition'], delimiter=options['delimeter'], stored=options['stored'], serde=options['serde'], outputformat=options['outputformat'], external=flags['e'], recreate=flags['d'], filepath=options['csvpath'], overwrite=flags['o'])
def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() if not options["schema"]: options["schema"] = "default" out = hive.get_results(hql=options["hql"], schema=options["schema"]) if options["out"]: with open(out, "rw") as io: io.writelines(out) io.close() else: print out
def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() if not options['schema']: options['schema'] = 'default' out = hive.get_results(hql=options['hql'], schema=options['schema']) if options['out']: with open(out, 'rw') as io: io.writelines(out) io.close() else: print out
def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() hive.create_csv_table( table=options["table"], field=options["columns"], partition=options["partition"], delimiter=options["delimeter"], stored=options["stored"], serde=options["serde"], outputformat=options["outputformat"], external=flags["e"], recreate=flags["d"], filepath=options["csvpath"], overwrite=flags["o"], )
def main(): if not options["columns"] and not options["struct"]: grass.fatal("Must be defined <attributes> or <struct> parameter") conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() hive.create_geom_table( table=options["table"], field=options["columns"], stored=options["stored"], serde=options["serde"], outputformat=options["outformat"], external=flags["e"], recreate=flags["d"], filepath=options["jsonpath"], overwrite=flags["o"], )
def main(): conn = ConnectionManager() conn.get_current_connection(options["driver"]) hive = conn.get_hook() if flags["p"]: hive.show_tables() if flags["d"]: if not options["table"]: grass.fatal("With flag <d> table must be defined") hive.describe_table(options["table"], True) if flags["h"]: if not options["table"]: grass.fatal("With flag <h> table must be defined") print(hive.find_table_location(options["table"])) if options["path"]: hive.check_for_content(options["path"])
def main(): tmp_dir = os.path.join(get_tmp_folder(), options['out']) if os.path.exists(tmp_dir): shutil.rmtree(tmp_dir) transf = GrassHdfs(options['driver']) table_path = options['hdfs'] if options['table']: conn = ConnectionManager() conn.get_current_connection('hiveserver2') if not conn.get_current_connection('hiveserver2'): grass.fatal("Cannot connet to hive for table description. " "Use param hdfs without param table") hive = conn.get_hook() table_path = hive.find_table_location(options['table']) tmp_dir = os.path.join(tmp_dir,options['table']) if not transf.download(hdfs=table_path, fs=tmp_dir): return files = os.listdir(tmp_dir) map_string='' for block in files: map='%s_%s'%(options['out'],block) block=os.path.join(tmp_dir,block) map_build = GrassMapBuilderEsriToEsri(block, map, options['attributes']) try: map_build.build() map_string+='%s,'%map except Exception ,e: grass.warning("Error: %s\n Map < %s > conversion failed"%(e,block))
def main(): tmp_dir = os.path.join(get_tmp_folder(), options['out']) if os.path.exists(tmp_dir): shutil.rmtree(tmp_dir) transf = GrassHdfs(options['driver']) table_path = options['hdfs'] if options['table']: conn = ConnectionManager() conn.get_current_connection('hiveserver2') if not conn.get_current_connection('hiveserver2'): grass.fatal("Cannot connet to hive for table description. " "Use param hdfs without param table") hive = conn.get_hook() table_path = hive.find_table_location(options['table']) tmp_dir = os.path.join(tmp_dir,options['table']) if not transf.download(hdfs=table_path, fs=tmp_dir): return files = os.listdir(tmp_dir) map_string = '' for block in files: map = '%s_%s' % (options['out'],block) block = os.path.join(tmp_dir,block) map_build = GrassMapBuilderEsriToEsri(block, map, options['attributes']) try: map_build.build() map_string += '%s,' % map except Exception,e: grass.warning("Error: %s\n Map < %s > conversion failed" % (e,block))
def main(): # add new connection conn = ConnectionManager() if options['connectionuri']: conn.set_connection_uri(options['connectionuri']) conn.add_connection() conn.test_connection() return if options['host'] and options['driver'] and options['conn_id']: conn.set_connection(conn_type=options['driver'], conn_id=options['conn_id'], host=options['host'], port=options['port'], login=options['login'], password=options['passwd'], schema=options['schema']) conn.add_connection() conn.test_connection() return if options['rmid']: conn.remove_conn_Id(options['rmid']) return # print table of connection elif flags['c']: conn.show_connections() return # drop table with connections elif flags['r']: conn.drop_connection_table() conn.show_connections() return # print active connection elif flags['p']: conn.show_active_connections() return elif flags['t']: if options['driver']: conn.test_connection(options['driver']) else: print('< driver > is not set') return elif flags['a']: if not options['driver'] and options['conn_id']: conn.set_active_connection(options['driver'], options['conn_id']) else: grass.fatal("ERROR parameter < driver > and 'conn_id' must be set")
def main(): # add new connection conn = ConnectionManager() if options["connectionuri"]: conn.set_connection_uri(options["connectionuri"]) conn.add_connection() conn.test_connection() return if options["host"] and options["driver"] and options["conn_id"]: conn.set_connection( conn_type=options["driver"], conn_id=options["conn_id"], host=options["host"], port=options["port"], login=options["login"], password=options["passwd"], schema=options["schema"], ) conn.add_connection() conn.test_connection() return if options["rmid"]: conn.remove_conn_Id(options["rmid"]) return # print table of connection elif flags["c"]: conn.show_connections() return # drop table with connections elif flags["r"]: conn.drop_connection_table() conn.show_connections() return # print active connection elif flags["p"]: conn.show_active_connections() return elif flags["t"]: if options["driver"]: conn.test_connection(options["driver"]) else: print("< driver > is not set") return elif flags["a"]: if not options["driver"] and options["conn_id"]: conn.set_active_connection(options["driver"], options["conn_id"]) else: grass.fatal("ERROR parameter < driver > and 'conn_id' must be set")