刚开始接触Pentaho的 kettle desktop版本。我们这里主要应用其与hadoop及 hive 的关联进行数据处理。 kettle 的版本是4.4,使用的过程还是挺顺利的,顺利的建立好了一个转换任务,将 hive 中的数据提取到了本地文件。但是打开一看,所以 utf8 的 中文 全都是
刚开始接触Pentaho的kettle desktop版本。我们这里主要应用其与hadoop及hive的关联进行数据处理。kettle的版本是4.4,使用的过程还是挺顺利的,顺利的建立好了一个转换任务,将hive中的数据提取到了本地文件。但是打开一看,所以utf8的中文全都是乱码。而且kettle现在只支持到了hive0.7版本,还没支持到0.8,所以无法正确提取hive的meta信息,但是不影响HQL的正常运行。
只能先看看kettle是如何使用hive的jdbc连接的。我先将hive-jdbc.0.8.1.ar拷贝到{kettlehome}/libext/JDBC下,直接造成无法正常连接hive。
在该目录下存在jar文件hive-jdbc-0.7.0-pentaho-1.0.2.jar,这个类是一个适配类,不真正实现hive的jdbc连接。
而是通过反射的方式,找到classpath下的hivejdbc类,即存在于{kettlehome}\plugins\pentaho-big-data-plugin\hadoop-configurations\hadoop-20\lib\hive-jdbc-0.7.0-pentaho-1.0.2.jar这个jar文件,该文件用于真实的调用hive。
我们就来看一下这个jar中的实现。可以先从以下url中获取source文件。http://repo.pentaho.org/artifactory/repo/org/apache/hive/hive-jdbc/0.7.0-pentaho-1.0.2/hive-jdbc-0.7.0-pentaho-1.0.2-sources.jar 下载解压后,倒入到你自己的一个新建java工程中,并引入相关的类库,可以使之正常编译。
StructObjectInspector soi = (StructObjectInspector) serde.getObjectInspector();List fieldRefs = soi.getAllStructFieldRefs();//Object data = serde.deserialize(new BytesWritable(rowStr.getBytes()));//我们将该行屏蔽Object data = serde.deserialize(new BytesWritable(rowStr.getBytes("UTF-8")));//使用本行
然后将编译后的class文件加入到hive-jdbc-0.7.0-pentaho-1.0.2.jar
重新启动kettle。
然后再跑一下流程,正常了。当然,如果你的系统环境本身编码就是utf8的,应该不会出现这样的问题。
原文地址:Kettle连接Hive 中文乱码问题解决方案, 感谢原作者分享。

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
