hive如何从HDFS中存在的文件创建表?(How hive create a table from a file present in HDFS?)
我是HDFS和HIVE的新手。 在阅读了一些书籍和文档后,我得到了一些介绍。 我有一个关于在HIVE中创建表格的问题,其中文件存在于HDFS中。 我有这个文件在HDFS中有300个字段。 我想在HDFS中创建一个访问该文件的表。 但我想利用这个文件中的30个字段。 我的问题是1. hive是否创建了一个单独的文件目录? 2.我是否必须先创建配置表并从HDFS导入数据? 3.由于我想创建一个包含300列中30列的表,因此hive是否只创建了包含30列的文件? 4.我是否必须创建一个包含30列的单独文件并导入HDFS,然后创建指向HDFS目录的hive表?
I am new to HDFS and HIVE. I got some introduction of both after reading some books and documentation. I have a question regarding creation of a table in HIVE for which file is present in HDFS. I have this file with 300 fields in HDFS. I want to create a table accessing this file in HDFS. But I want to make use of say 30 fields from this file. My questions are 1. Does hive create a separate file directory? 2. Do I have to create hive table first and import data from HDFS? 3. Since I want to create a table with 30 columns out of 300 columns, Does hive create a file with only those 30 columns? 4. Do I have to create a separate file with 30 columns and import into HDFS and then create hive table pointing to HDFS directory?
原文:https://stackoverflow.com/questions/43649735
最满意答案
您试图在Python 3中使用Python 2中的函数 。Python 2的
apply()
函数已被弃用,完全从Python 3中移除,并且不应该在Python 2中使用。 从文档:自2.3版弃用 :使用
function(*args, **keywords)
而不是apply(function, args, keywords)
(请参阅解包参数列表 )。改用
*args
:l.yview(*args)
和
if last: return map(None, *result)
You are trying to use a function from Python 2 in Python 3. The Python 2
apply()
function was already deprecated, removed completely from Python 3 and shouldn't be used in Python 2 either. From the documentation:Deprecated since version 2.3: Use
function(*args, **keywords)
instead ofapply(function, args, keywords)
(see Unpacking Argument Lists).Use
*args
instead:l.yview(*args)
and
if last: return map(None, *result)
相关问答
更多-
在Python中,不会将实例范围作为范围解析的一部分进行搜索。 如果你想在self上调用一个方法,那么你必须在它前面加上对self的引用。 self.growl(register) The instance scope is not searched as part of scope resolution in Python. If you want to call a method on self then you must prefix it with a reference to self. sel ...
-
“全局名称未定义”错误(“Global name is not defined” error)[2022-04-05]
我会假设你先调用Travel()函数。 如果Travel()被调用,您现在将输入一个值为'F'或'T'的字符串。 如果输入是'F', LocF()将被调用,在LocF()你返回了i但你没有定义它。 如果输入是'T', LocT()将被调用,并且由于在Travel()范围中没有i ,解释器会在外面寻找i 。 外面也没有i ,所以这个错误是可以理解的。 有几种方法可以修复你的代码,但是因为我不知道你想做什么,所以我无法进一步帮助。 而你的问题是关于静态和动态范围,而不是面向对象。 I will assume y ... -
名称'自我'未定义(name 'self' is not defined)[2024-01-03]
由于您想要自定义DetailView的查询集,因此正确的方法是覆盖get_queryset()函数。 请参阅DetailView文档,其中显示了方法解析顺序。 特别是, get_queryset() 。 所以你的代码会变成这样: class customerDetailView(DetailView): context_object_name = 'customerDetail' template_name = "customer.html" allow_empty = True ... -
名称spark未定义(name spark is not defined)[2023-07-21]
如果您的spark版本是1.0.1,则不应使用2.2.0版本的教程。 这些版本之间有重大变化。 在本网站上,您可以找到1.6.0的教程 。 在1.6.0教程之后,您必须使用textFile = sc.textFile("README.md")而不是textFile = spark.read.text("README.md") 。 If your spark version is 1.0.1 you should not use the tutorial for version 2.2.0. There ar ... -
您试图在Python 3中使用Python 2中的函数 。Python 2的apply()函数已被弃用,完全从Python 3中移除,并且不应该在Python 2中使用。 从文档: 自2.3版弃用 :使用function(*args, **keywords)而不是apply(function, args, keywords) (请参阅解包参数列表 )。 改用*args : l.yview(*args) 和 if last: return map(None, *result) You are trying ...
-
当名称已在同一模块中定义时,名称未定义错误(Name not defined error when name is already defined in the same module)[2021-12-31]
不,当class A的主体被执行时(立即执行), B尚未定义。 定义B后添加Ao : class A: pass class B: o = A() A.o = B() No, B is not yet defined when the body of class A is executed (which is immediately). Add A.o after B is defined: class A: pass class B: o = A() A.o = ... -
名称'_'未定义(Name '_' is not defined)[2022-09-21]
你错过了这个: from django.utils.translation import gettext as _ 从Django i18n文档中阅读更多信息。 这是Django / python项目中的惯用方法。 You miss this: from django.utils.translation import gettext as _ Read more info from Django i18n docs. It's an idiomatic method in Django/python p ... -
全局名称未定义错误(global name not defined error)[2022-03-17]
如果要在多块作用域中访问discount ,则必须将discount声明为全局。 discount = 0 def finddiscount(quantity): ... global discount # Needed to modify global copy of discount discount = 1 You have to declare discount as a global if you want to access it in a multi bloc ... -
windows vs ubuntu NameError:未定义全局名称(windows vs ubuntu NameError: global name is not defined)[2024-03-19]
问题是当脚本生成另一个进程并执行run函数时,未定义test变量。 仅当__name__变量设置为"__main__"时才设置test变量。 解释器在生成的进程中将__name__值更改为“ __name__ "__parents_main__" ,因此不会定义test 。 正如你所想的那样,删除if语句会设置变量,因为这不再取决于__name__被设置为'__main__'但正如下面的注释所指出的那样,这将导致自我复制的工作线程并导致错误。 加: if __name__=='__main__' or __ ... -
NameError:未定义名称“MenuItems” 当您收到该错误时,您可以在定义之前或导入之前使用某个名称。 为了避免这种情况,你需要from x import MenuItem或像MenuItem = ...或class MenuItem这样的定义MenuItem = ... 我在那之前观看了一些视频,教练导入了这样的视频: from database_setup import Base, Restaurant, MenuItem 因此,如果您已经关注了视频,那么您应该在database_setup ...