我在蜂巢表中有并行数组,如下所示:
import React, { Component } from 'react'
import ReactQuill from 'react-quill'
import 'react-quill/dist/quill.snow.css'
import fire from '../../firebase'
import * as Icon from 'react-feather'
const CustomButton = () => <Icon.Save onClick={NoteEditor.modules.toolbar.handlers.writeUserNotes} />
const CustomToolbar = () => (
<div id='toolbar'>
<select className='ql-header' defaultValue={''} onChange={e => e.persist()}>
<option value='1' />
<option value='2' />
<option selected />
</select>
<button className='ql-bold' />
<button className='ql-italic' />
<select className='ql-color'>
<option value='red' />
<option value='green' />
<option value='blue' />
<option value='orange' />
<option value='violet' />
<option value='#d0d1d2' />
<option selected />
</select>
<button className='ql-save'>
<CustomButton />
</button>
</div>
)
export default class NoteEditor extends Component {
constructor (props) {
super(props)
this.state = { text: '' }
this.handleChange = this.handleChange.bind(this)
}
writeUserNotes (user) {
}
handleChange (value) {
this.setState({ text: value })
}
render () {
return (
<div className='text-editor w-80'>
<CustomToolbar />
<ReactQuill
onChange={this.handleChange}
modules={NoteEditor.modules}
formats={NoteEditor.formats}
theme={'snow'}
/>
</div>
)
}
}
NoteEditor.modules = {
toolbar: {
container: '#toolbar',
handlers: {
writeUserNotes: () => {
fire.database().ref('/notes').set({
note:
})
}
}
},
clipboard: {
matchVisual: false
}
}
NoteEditor.formats = [
'header',
'font',
'size',
'bold',
'italic',
'underline',
'strike',
'blockquote',
'list',
'bullet',
'indent',
'link',
'image',
'color'
]
如何将它们压缩在一起(如python zip函数),以便获得结构列表,如
with tbl as ( select array(1,2,3) as x, array('a','b','c') as y)
select x,y from tbl;
x y
[1,2,3] ["a","b","c"]
1 row selected (0.108 seconds)
答案 0 :(得分:1)
您可以posexplode
使其在array
中给出位置,然后将其用于过滤。
select x,y,collect_list(struct(val1,val2))
from tbl
lateral view posexplode(x) t1 as p1,val1
lateral view posexplode(y) t2 as p2,val2
where p1=p2
group by x,y
答案 1 :(得分:0)
这是我为避免双重爆炸而做的尝试:
with tbl as (select array(1,2,3,4,5) as x, array('a','b','c','d','e') as y)
select collect_list(struct(xi, y[i-1]))
from tbl lateral view posexplode(x) tbl2 as xi, i;
但是,我遇到了一个奇怪的错误:
Error: Error while compiling statement: FAILED: IllegalArgumentException Size requested for unknown type: java.util.Collection (state=42000,code=40000)
我能够使用
解决它set hive.execution.engine=mr;
不如使用spark或tez作为后端那样快速/优化。