Firebase BigQuery迁移bash错误

时间:2018-07-10 10:43:09

标签: firebase google-bigquery firebase-analytics

我正在使用Google的标准工作流程来运行从旧数据集到新数据集(Migration steps)的迁移。我估算出缺少的值,例如属性ID,BigQuery ID等。当我运行bash脚本时,发生以下错误吗?

Migrating mindfulness.com_mindfulness_ANDROID.app_events_20180515
--allow_large_results --append_table --batch --debug_mode --destination_table=analytics_171690789.events_20180515 --noflatten_results --nouse_legacy_sql --parameter=firebase_app_id::1:437512149764:android:0dfd4ab1e9926c7c --parameter=date::20180515 --parameter=platform::ANDROID#platform --project_id=mindfulness --use_gce_service_account
FATAL Flags positioning error: Flag '--project_id=mindfulness' appears after final command line argument. Please reposition the flag.
Run 'bq help' to get help.

在stackoverflow和Google上,我找不到解决方案。有人知道如何解决吗?

我的migration.sh脚本(对ID进行了少量修改以保持匿名)

# Analytics Property ID for the Project. Find this in Analytics Settings in Firebase
PROPERTY_ID=171230123
# Bigquery Export Project
BQ_PROJECT_ID="mindfulness" #(e.g., "firebase-public-project")
# Firebase App ID for the app.
FIREBASE_APP_ID="1:123412149764:android:0dfd4ab1e1234c7c" #(e.g., "1:300830567303:ios:
# Dataset to import from.
BQ_DATASET="com_mindfulness_ANDROID" #(e.g., "com_firebase_demo_IOS")
# Platform
PLATFORM="ANDROID"#"platform of the app. ANDROID or IOS"
# Date range for which you want to run migration, [START_DATE,END_DATE]
START_DATE=20180515
END_DATE=20180517
# Do not modify the script below, unless you know what you are doing :)
startdate=$(date -d"$START_DATE"  +%Y%m%d) || exit -1
enddate=$(date -d"$END_DATE"  +%Y%m%d) || exit -1
# Iterate through the dates.
DATE="$startdate"
while [ "$DATE" -le "$enddate" ]; do
# BQ table constructed from above params.
BQ_TABLE="$BQ_PROJECT_ID.$BQ_DATASET.app_events_$DATE"
echo "Migrating $BQ_TABLE"
cat migration_script.sql | sed -e "s/SCRIPT_GENERATED_TABLE_NAME
$BQ_TABLE/g" | bq query \
    --debug_mode \
    --allow_large_results \
    --noflatten_results \
    --use_legacy_sql=False \
    --destination_table analytics_$PROPERTY_ID.events_$DATE \
    --batch \
    --append_table \
    --parameter=firebase_app_id::$FIREBASE_APP_ID \
    --parameter=date::$DATE \
    --parameter=platform::$PLATFORM \
    --project_id=$BQ_PROJECT_ID
temp=$(date -I -d "$DATE + 1 day")
DATE=$(date -d "$temp" +%Y%m%d)
done
exit
# END OF SCRIPT

1 个答案:

答案 0 :(得分:0)

如果您查看脚本的输出,则该脚本的文本位置正好位于乱序的标志的前面:

prototype

我很确定您希望平台是--parameter=platform::ANDROID#platform --project_id=mindfulness,而不是ANDROID

我怀疑您可以通过在字符串末尾和内联注释之间放置一个空格来解决此问题。所以你有这样的东西:

ANDROID#platform

为了安全起见,您可能希望完全删除每行末尾的注释。