将 Firestore 数据以表格格式存储在 BigQuery 中,并使用 Firebase 导出集合到 BigQuery 扩展程序

问题描述

我正在尝试将现有数据和所有未来数据从 Firestore 数据库导出到 BigQuery。

我正在使用 Export Collections to BigQuery firebase 扩展程序,它将我的新数据导出到 BigQuery。 Users_raw_latest 表中有正确的数据。

问题是它没有我想要的表格格式的数据。我希望架构字段是集合属性。该表提供了以下架构:

enter image description here

data 字段包含集合中每个文档的 json。

当我尝试使用 BigQuery guide 在 BigQuery 中存储旧数据(在安装扩展之前已经生成的数据)时,它创建了另一个表 Users 并具有我想要的完全正确的架构,即文档属性是表的列。

有什么办法可以将这个现有的用户表(我不介意再次删除和创建一个)与文档属性一起使用,因为列中填充有使用此扩展程序或任何替代自动化插入 Firestore 中的新数据?还是我必须编写自己的函数才能这样做?

解决方法

doc 中所述,您需要使用 void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo',theme: ThemeData( primarySwatch: Colors.blue,),home: MyHomePage(),); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int rowIndx = 0; int columnIndx = 0; @override Widget build(BuildContext context) { return Scaffold( body: PageView.builder( onPageChanged: (index) { rowIndx = index; },scrollDirection: Axis.vertical,controller: PageController(initialPage: 0,viewportFraction: 0.63),itemCount: 5,itemBuilder: (_,index) { return PageView.builder( onPageChanged: (index) { columnIndx = index; },controller: PageController(initialPage: 0,itemCount: sampleCard.length,itemBuilder: (context,ind) { return GestureDetector( onTap: () { print( 'column : $columnIndx in horizontal scroll > left and right'); print( 'row : $rowIndx in vertical scroll > up and down'); },child: sampleCard[ind],); }); }),); } } List sampleCard = [ Container( margin: EdgeInsets.all(50.0),decoration: BoxDecoration( color: Colors.red,child: Center( child: Text( 'column 0',)),Container( margin: EdgeInsets.all(50.0),decoration: BoxDecoration( color: Colors.blueGrey,child: Center( child: Text( 'column 1',decoration: BoxDecoration( color: Colors.yellow,child: Center( child: Text( 'column 2',];``` 脚本生成自己的架构视图

您只需要提供一个 JSON 架构文件来描述您的数据 结构,schema-views 脚本将创建视图。

详细文档为 here

新架构将包含与您将定义的 JSON 架构文件中声明的字段相对应的列,添加一组“技术”列(fs-bq-schema-views、{ {1}}、document_namedocument_id),如下所示:

enter image description here