小编Pra*_*jot的帖子

在BigQuery中将行转换为列(Pivot实现)

我想生成一个新表,并使用BigQuery将所有键值对作为列名和值作为各自的值放置.

例:

**Key**                  **Value**
channel_title           Mahendra Guru    
youtube_id              ugEGMG4-MdA  
channel_id              UCiDKcjKocimAO1tV    
examId                  72975611-4a5e-11e5   
postId                  1189e340-b08f 

channel_title           Ab Live  
youtube_id              3TNbtTwLY0U  
channel_id              UCODeKM_D6JLf8jJt    
examId                  72975611-4a5e-11e5   
postId                  0c3e6590-afeb
Run Code Online (Sandbox Code Playgroud)

我想将其转换为:

**channel_title   youtube_id   channel_id         examId               postId**
Mahendra Guru   ugEGMG4-MdA  UCiDKcjKocimAO1tV  72975611-4a5e-11e5   1189e340-b08f
Ab Live         3TNbtTwLY0U  UCODeKM_D6JLf8jJt  72975611-4a5e-11e5   0c3e6590-afeb
Run Code Online (Sandbox Code Playgroud)

如何使用BigQuery做到这一点?

sql google-bigquery google-cloud-platform

12
推荐指数
1
解决办法
1万
查看次数

Apache Airflow调度程序不会在计划时触发DAG

当我计划每天在特定时间运行DAG时,DAG执行根本不会发生.但是,当我重新启动Airflow网络服务器和调度程序时,DAG在该特定日期的预定时间执行一次,并且从第二天开始不执行.我使用的是带有python 2.7.6的Airflow版本v1.7.1.3.这里是DAG代码:

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta

import time
n=time.strftime("%Y,%m,%d")
v=datetime.strptime(n,"%Y,%m,%d")
default_args = {
    'owner': 'airflow',
    'depends_on_past': True,
    'start_date': v,
    'email': ['airflow@airflow.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=10),

}

dag = DAG('dag_user_answer_attempts', default_args=default_args, schedule_interval='03 02 * * *')

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='user_answer_attempts',
    bash_command='python /home/ubuntu/bigcrons/appengine-flask-skeleton-master/useranswerattemptsgen.py',
    dag=dag)
Run Code Online (Sandbox Code Playgroud)

难道我做错了什么?

python apache cron directed-acyclic-graphs airflow

4
推荐指数
2
解决办法
9017
查看次数

APL:向量/数组中'n'个相邻数字的平均向量

如何计算APL中矢量中n个相邻数的平均向量?

考虑向量:a←2 3 4 5 6

输入:2应该返回2.5 3.5 4.5 5.5,

3应该返回3 4 5,

4应返回3.5 4.5.

avg←(+/a)÷⍴a在这种情况下无济于事!

vector apl

2
推荐指数
1
解决办法
173
查看次数