首页 > 其他分享 >dremio 读取 jsonl 格式支持

dremio 读取 jsonl 格式支持

时间:2024-05-02 11:33:05浏览次数:14  
标签:dremio 读取 defaultFormats jsonl 插件 put new

实际上属于dremio 社区一个问题,内部实际上是dremio 对于格式化插件支持的问题, 不少是基于文件格式硬编码的,尽管
我们可以自定义格式化插件,但是对于已经支持的就有点不是很方便了,可以直接复用现有的,以下说明下修改以及处理

直接修改JSONFormatPlugin 代码支持jsonl

  • 参考如下
    FormatCreator.java
public static Map<String, FormatPluginConfig> getDefaultFormats() {
  Map<String, FormatPluginConfig> defaultFormats = new TreeMap<>();
  defaultFormats.put("csv", createTextFormatPlugin(false, ",", Lists.newArrayList("csv")));
  defaultFormats.put("csvh", createTextFormatPlugin(true, ",", Lists.newArrayList("csvh")));
  defaultFormats.put("tsv", createTextFormatPlugin(false, "\t", Lists.newArrayList("tsv")));
  defaultFormats.put("psv", createTextFormatPlugin(false, "|", Lists.newArrayList("psv", "tbl")));
  defaultFormats.put("txt", createTextFormatPlugin(false, "\u0000", Lists.newArrayList("txt")));
  TextFormatConfig psva = createTextFormatPlugin(false, "|", Lists.newArrayList("psva", "tbla"));
  psva.autoGenerateColumnNames = true;
  defaultFormats.put("psva", psva);
 
  defaultFormats.put("parquet", new ParquetFormatConfig());
  defaultFormats.put("json", new JSONFormatPlugin.JSONFormatConfig());
  defaultFormats.put("jsonl", new JSONFormatPlugin.JSONFormatConfig());
  defaultFormats.put("dremarrow1", new ArrowFormatPluginConfig());
  defaultFormats.put("iceberg", new IcebergFormatConfig());
  defaultFormats.put("delta", new DeltaLakeFormatConfig());
  defaultFormats.put("xls", new ExcelFormatPluginConfig(true));
  defaultFormats.put("excel", new ExcelFormatPluginConfig(false));
  return defaultFormats;
}

JSONFormatPlugin.java

public static class JSONFormatConfig implements FormatPluginConfig {
 
  public List<String> extensions = ImmutableList.of("json","jsonl");
  private static final List<String> DEFAULT_EXTS = ImmutableList.of("json","jsonl");
  .....

基于标准格式化插件模式

实际上就是复制JSONFormatPlugin的代码,自己修改,然后编译一个,复制到dremio的classpath 中

构建以及替换

方法就比较多了,可以是直接jar class 替换的,也可以是按照标准jar 文件存放的

  • class 替换的参考命令
jar uf dremio-sabot-kernel-25.0.0-202404051521110861-ed9515a8.jar   com/dremio/exec/store/dfs/FormatCreator.class
jar uf dremio-sabot-kernel-25.0.0-202404051521110861-ed9515a8.jar   com/dremio/exec/store/easy/json/JSONFormatPlugin\$JSONFormatConfig.class
  • 标准格式化插件模式
    直接放到dremio jars 目录就行了

参考效果

  • s3 数据存储

  • 通过修改表元数据进行自动提升
    自动提升就会使用到格式化插件
ALTER TABLE s3.dalong.appdemo REFRESH METADATA AUTO PROMOTION

效果

  • 查询

说明

以上是一个简单说明,实际上对于格式化插件的开发基本套路也是这样的

参考资料

https://jsonlines.org/
https://www.atatus.com/glossary/jsonl/
https://www.cnblogs.com/rongfengliang/p/18141296

标签:dremio,读取,defaultFormats,jsonl,插件,put,new
From: https://www.cnblogs.com/rongfengliang/p/18170044

相关文章

  • 使用@lakehouse-rs/flight-sql-client nodejs api 快速访问dremio 服务
    @lakehouse-rs/flight-sql-client是基于rust开发的nodearrowflightsqlclient,dremio目前也是推荐基于arrowflightsql的访问模式参考代码package.json{"name":"node-arrow-flight-sql","version":"1.0.0","ma......
  • Go语言系列——自定义错误、panic和recover、函数是一等公民(头等函数)、反射、读取文件
    文章目录31-自定义错误使用New函数创建自定义错误使用Errorf给错误添加更多信息使用结构体类型和字段提供错误的更多信息使用结构体类型的方法来提供错误的更多信息32-panic和recover什么是panic?什么时候应该使用panic?panic示例发生panic时的deferrecoverpanic,re......
  • dremio 日志配置
    dremio对于日志的配置支持基于系统属性以及环境变量的模式,对于环境变量实际上也是使用的系统属性参考配置系统属性可以直接通过dremio-env文件添加-Ddremio.log.path=/opt/dremio/logs环境变量直接添加环境变量就可以了DREMIO_LOG_DIR=/o......
  • 读取文章和打印
    importjava.io.*;importjava.util.ArrayList;importjava.util.HashMap;importjava.util.List;importjava.util.Map;importjava.util.regex.Matcher;importjava.util.regex.Pattern;publicstaticvoidmain(String[]args){StringfilePath="D:\\黄帝内经......
  • python读取xml中的字段值
    importxml.etree.ElementTreeasETxml_string='''<?xmlversion="1.0"encoding="utf-8"?><rssxmlns:atom="http://www.w3.org/2005/Atom"xmlns:media="http://search.yahoo.com/mrss/"......
  • dremio The source [xxxx] is currently unavailable. Metadata is not accessible; p
    最近在dremio25.0版本碰到了一些问题,以下说明下原因以及处理问题现象问题实际上此问题是执行节点报的错误,并不是协调节点的,早期一直以为是协调节点的,结果通过分析调试发现是协调节点报的错误Thesource[xxxx]iscurrentlyunavailable.Metadataisnotaccess......
  • 自动化测试框架-数据读取
     1.准备数据:数据格式为{json},放在json文件内,例如这样:   2.工具类:读取.json文件,保存在Map<testCaseName,JSONObject>内publicstaticMap<String,JSONObject>jsonToSearchFilter(StringfileName)throwsIOException{Map<String,JSONObject>result=ne......
  • python读取文件指定行的三种方法
    1.行遍历实现在python中如果要将一个文件完全加载到内存中,通过file.readlines()即可,但是在文件占用较高时,我们是无法完整的将文件加载到内存中的,这时候就需要用到python的file.readline()进行迭代式的逐行读取:filename='hello.txt'withopen(filename,'r')asfile:l......
  • dotnet appsettings 配置文件读取
    Console.Config\Program.csusingMicrosoft.Extensions.Configuration;varbasePath=Directory.GetCurrentDirectory();varconfiguration=newConfigurationBuilder().SetBasePath(basePath)//设置基本路径.AddJsonFile("appsettings.json")//添......
  • Java读取网址信息
    Java读取网址信息今天的需求是根据接口获取JSON数据并存入,之前只会前端用Ajax或者Axios去处理显示出来没想过后端也要拿,没有思路于是查找,发现都是基础以前用的还是太少了,特此总结,后续有需要再补充。1.读取get请求,无需参数publicstaticStringget(StringurlStr){//......