mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
[sqllab] add support for results backends (#1377)
* [sqllab] add support for results backends Long running SQL queries (beyond the scope of a web request) can now use a k/v store to hold their result sets. * Addressing comments, fixed js tests * Fixing mysql has gone away * Adressing more comments * Touchups
This commit is contained in:
committed by
GitHub
parent
7dfe891cc1
commit
6fb3b305ad
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import SyntaxHighlighter from 'react-syntax-highlighter';
|
||||
import { github } from 'react-syntax-highlighter/dist/styles';
|
||||
|
||||
const HighlightedSql = (props) => {
|
||||
const sql = props.sql || '';
|
||||
let lines = sql.split('\n');
|
||||
if (lines.length >= props.maxLines) {
|
||||
lines = lines.slice(0, props.maxLines);
|
||||
lines.push('{...}');
|
||||
}
|
||||
let shownSql = sql;
|
||||
if (props.shrink) {
|
||||
shownSql = lines.map((line) => {
|
||||
if (line.length > props.maxWidth) {
|
||||
return line.slice(0, props.maxWidth) + '{...}';
|
||||
}
|
||||
return line;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<SyntaxHighlighter language="sql" style={github}>
|
||||
{shownSql}
|
||||
</SyntaxHighlighter>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
HighlightedSql.defaultProps = {
|
||||
maxWidth: 60,
|
||||
maxLines: 6,
|
||||
shrink: false,
|
||||
};
|
||||
|
||||
HighlightedSql.propTypes = {
|
||||
sql: React.PropTypes.string,
|
||||
maxWidth: React.PropTypes.number,
|
||||
maxLines: React.PropTypes.number,
|
||||
shrink: React.PropTypes.bool,
|
||||
};
|
||||
|
||||
export default HighlightedSql;
|
||||
Reference in New Issue
Block a user