首页 \ 问答 \ hive如何从HDFS中存在的文件创建表?(How hive create a table from a file present in HDFS?)

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
更新时间:2023-05-30 17:05

最满意答案

您试图在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 of apply(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 ...
  • 我会假设你先调用Travel()函数。 如果Travel()被调用,您现在将输入一个值为'F'或'T'的字符串。 如果输入是'F', LocF()将被调用,在LocF()你返回了i但你没有定义它。 如果输入是'T', LocT()将被调用,并且由于在Travel()范围中没有i ,解释器会在外面寻找i 。 外面也没有i ,所以这个错误是可以理解的。 有几种方法可以修复你的代码,但是因为我不知道你想做什么,所以我无法进一步帮助。 而你的问题是关于静态和动态范围,而不是面向对象。 I will assume y ...
  • 由于您想要自定义DetailView的查询集,因此正确的方法是覆盖get_queryset()函数。 请参阅DetailView文档,其中显示了方法解析顺序。 特别是, get_queryset() 。 所以你的代码会变成这样: class customerDetailView(DetailView): context_object_name = 'customerDetail' template_name = "customer.html" allow_empty = True ...
  • 如果您的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 ...
  • 不,当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 = ...
  • 你错过了这个: 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 ...
  • 如果要在多块作用域中访问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 ...
  • 问题是当脚本生成另一个进程并执行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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)