extended frontend

This commit is contained in:
Pedro 2014-11-17 15:39:27 +01:00
parent 085397866e
commit f8d56c2a54
3 changed files with 53 additions and 12 deletions

View File

@ -4,7 +4,8 @@
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="hyrise-sql-connector.js"></script>
<link href="style.css" rel="stylesheet">
<link href="style.css" rel="stylesheet" />
<title>Hyrise SQL Frontend</title>
</head>
<body>
@ -76,12 +77,23 @@
$(function() {
function addSampleQuery(name, query) {
var btn = $('<button type="button" class="btn btn-success">' + name + '</button>');
btn.click(function() { $('#queryInput').val(query); });
btn.click(function(evt) {
$('#queryInput').val(query);
if (!evt.shiftKey) {
$('#submitBtn').click();
}
});
$('#sampleQueries').append(btn);
}
function addBuggyQuery(name, query) {
var btn = $('<button type="button" class="btn btn-danger">' + name + '</button>');
btn.click(function() { $('#queryInput').val(query); });
btn.click(function(evt) {
$('#queryInput').val(query);
if (!evt.shiftKey) {
$('#submitBtn').click();
}
});
$('#buggyQueries').append(btn);
}
@ -164,18 +176,30 @@ $(function() {
return true;
});
addSampleQuery('Load Tables', '\
CREATE TABLE students FROM TBL FILE \'test/students.tbl\';\n\
CREATE TABLE test FROM TBL FILE \'test/lin_xxs.tbl\';');
addSampleQuery('SELECT 1', 'SELECT * FROM students;')
addSampleQuery('SELECT 2', 'SELECT name, city, grade FROM (SELECT * FROM students WHERE city = \'Potsdam\') t1 WHERE grade <= 1.5 OR grade >= 3.5;');
addSampleQuery('GROUP', 'SELECT city, AVG(grade) AS average|, MIN(grade) AS best, MAX(grade) AS worst FROM students GROUP BY city;');
addSampleQuery('UNION', 'SELECT * FROM students WHERE grade = 1.3 UNION SELECT * FROM students WHERE grade = 3.7;');
addSampleQuery('JOIN', 'SELECT * FROM students t1 JOIN students t2 ON t1.student_number = t2.student_number');
addBuggyQuery('GROUP', 'SELECT AVG(grade) FROM (SELECT city, AVG(grade) FROM students GROUP BY city) t1');
addBuggyQuery('UNION', 'SELECT name FROM students WHERE grade > 2.0 UNION SELECT name FROM students');
//////////////////////////////////////////////////
// Load sample queries
$.get('sample-queries.sql', function(data) {
var lines = data.split('\n');
var name, query = "";
$.each(lines, function(i, line) {
if (line[0] == '#') {
// New query
if (name) addSampleQuery(name, query);
name = line.substring(1);
query = "";
} else {
query += line + '\n';
}
});
if (name) addSampleQuery(name, query);
});
//////////////////////////////////////////////////
});
</script>
</body>

2
frontend-hyrise/run_server.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
python -m SimpleHTTPServer 10101

View File

@ -0,0 +1,15 @@
# Load Tables
CREATE TABLE IF NOT EXISTS students FROM TBL FILE 'test/students.tbl';
CREATE TABLE IF NOT EXISTS test FROM TBL FILE 'test/lin_xxs.tbl';
CREATE TABLE IF NOT EXISTS companies FROM TBL FILE 'test/tables/companies.tbl';
CREATE TABLE IF NOT EXISTS employees FROM TBL FILE 'test/tables/employees.tbl';
# SELECT (1)
SELECT * FROM students;
# SELECT (2)
SELECT name, city, grade FROM (SELECT * FROM students WHERE city = 'Potsdam') t1 WHERE grade <= 1.5 OR grade >= 3.5;
# GROUP
SELECT city, AVG(grade) AS average|, MIN(grade) AS best, MAX(grade) AS worst FROM students GROUP BY city;
# UNION
SELECT * FROM students WHERE grade = 1.3 UNION SELECT * FROM students WHERE grade = 3.7;
# JOIN
SELECT * FROM companies JOIN employees ON company_id = employee_company_id