├── .github ├── ISSUE_TEMPLATE │ └── config.yml └── workflows │ └── ci.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── SQL-compiler ├── compile-jit.sh ├── pom.xml ├── psqlsltbugs.txt ├── run-tests.sh ├── sql-to-dbsp ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── dbsp │ │ │ ├── sqlCompiler │ │ │ ├── CompilerMain.java │ │ │ ├── README │ │ │ ├── circuit │ │ │ │ ├── DBSPCircuit.java │ │ │ │ ├── DBSPNode.java │ │ │ │ ├── DBSPPartialCircuit.java │ │ │ │ ├── IDBSPDeclaration.java │ │ │ │ ├── IDBSPInnerNode.java │ │ │ │ ├── IDBSPNode.java │ │ │ │ ├── IDBSPOuterNode.java │ │ │ │ ├── operator │ │ │ │ │ ├── DBSPAggregateOperator.java │ │ │ │ │ ├── DBSPAggregateOperatorBase.java │ │ │ │ │ ├── DBSPConstantOperator.java │ │ │ │ │ ├── DBSPDifferentialOperator.java │ │ │ │ │ ├── DBSPDistinctOperator.java │ │ │ │ │ ├── DBSPFilterOperator.java │ │ │ │ │ ├── DBSPFlatMapOperator.java │ │ │ │ │ ├── DBSPIncrementalAggregateOperator.java │ │ │ │ │ ├── DBSPIncrementalDistinctOperator.java │ │ │ │ │ ├── DBSPIncrementalJoinOperator.java │ │ │ │ │ ├── DBSPIndexOperator.java │ │ │ │ │ ├── DBSPIntegralOperator.java │ │ │ │ │ ├── DBSPJoinOperator.java │ │ │ │ │ ├── DBSPMapIndexOperator.java │ │ │ │ │ ├── DBSPMapOperator.java │ │ │ │ │ ├── DBSPNegateOperator.java │ │ │ │ │ ├── DBSPNoopOperator.java │ │ │ │ │ ├── DBSPOperator.java │ │ │ │ │ ├── DBSPSinkOperator.java │ │ │ │ │ ├── DBSPSourceOperator.java │ │ │ │ │ ├── DBSPSubtractOperator.java │ │ │ │ │ ├── DBSPSumOperator.java │ │ │ │ │ ├── DBSPUnaryOperator.java │ │ │ │ │ ├── DBSPWindowAggregateOperator.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── compiler │ │ │ │ ├── CompilerOptions.java │ │ │ │ ├── ICompilerComponent.java │ │ │ │ ├── README.md │ │ │ │ ├── backend │ │ │ │ │ ├── DBSPCompiler.java │ │ │ │ │ ├── ToCsvVisitor.java │ │ │ │ │ ├── ToDotVisitor.java │ │ │ │ │ ├── jit │ │ │ │ │ │ ├── BlockClosures.java │ │ │ │ │ │ ├── SimpleClosureParameters.java │ │ │ │ │ │ ├── ToJitInnerVisitor.java │ │ │ │ │ │ ├── ToJitVisitor.java │ │ │ │ │ │ ├── TypeCatalog.java │ │ │ │ │ │ ├── ir │ │ │ │ │ │ │ ├── IJITId.java │ │ │ │ │ │ │ ├── JITFunction.java │ │ │ │ │ │ │ ├── JITNode.java │ │ │ │ │ │ │ ├── JITParameter.java │ │ │ │ │ │ │ ├── JITParameterMapping.java │ │ │ │ │ │ │ ├── JITProgram.java │ │ │ │ │ │ │ ├── JITReference.java │ │ │ │ │ │ │ ├── cfg │ │ │ │ │ │ │ │ ├── JITBlock.java │ │ │ │ │ │ │ │ ├── JITBlockArguments.java │ │ │ │ │ │ │ │ ├── JITBlockDestination.java │ │ │ │ │ │ │ │ ├── JITBlockParameter.java │ │ │ │ │ │ │ │ ├── JITBlockReference.java │ │ │ │ │ │ │ │ ├── JITBlockTerminator.java │ │ │ │ │ │ │ │ ├── JITBranchTerminator.java │ │ │ │ │ │ │ │ ├── JITJumpTerminator.java │ │ │ │ │ │ │ │ ├── JITReturnTerminator.java │ │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ │ ├── instructions │ │ │ │ │ │ │ │ ├── JITBinaryInstruction.java │ │ │ │ │ │ │ │ ├── JITCastInstruction.java │ │ │ │ │ │ │ │ ├── JITConstantInstruction.java │ │ │ │ │ │ │ │ ├── JITCopyInstruction.java │ │ │ │ │ │ │ │ ├── JITFunctionCall.java │ │ │ │ │ │ │ │ ├── JITInstruction.java │ │ │ │ │ │ │ │ ├── JITInstructionPair.java │ │ │ │ │ │ │ │ ├── JITInstructionReference.java │ │ │ │ │ │ │ │ ├── JITIsNullInstruction.java │ │ │ │ │ │ │ │ ├── JITLiteral.java │ │ │ │ │ │ │ │ ├── JITLoadInstruction.java │ │ │ │ │ │ │ │ ├── JITMuxInstruction.java │ │ │ │ │ │ │ │ ├── JITSetNullInstruction.java │ │ │ │ │ │ │ │ ├── JITStoreInstruction.java │ │ │ │ │ │ │ │ ├── JITTupleLiteral.java │ │ │ │ │ │ │ │ ├── JITUnaryInstruction.java │ │ │ │ │ │ │ │ ├── JITUninitRowInstruction.java │ │ │ │ │ │ │ │ ├── JITValue.java │ │ │ │ │ │ │ │ ├── JITZSetLiteral.java │ │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ │ ├── operators │ │ │ │ │ │ │ │ ├── JITAggregateOperator.java │ │ │ │ │ │ │ │ ├── JITConstantOperator.java │ │ │ │ │ │ │ │ ├── JITDifferentiateOperator.java │ │ │ │ │ │ │ │ ├── JITDistinctOperator.java │ │ │ │ │ │ │ │ ├── JITFilterOperator.java │ │ │ │ │ │ │ │ ├── JITFlatMapOperator.java │ │ │ │ │ │ │ │ ├── JITIndexWithOperator.java │ │ │ │ │ │ │ │ ├── JITIntegrateOperator.java │ │ │ │ │ │ │ │ ├── JITJoinOperator.java │ │ │ │ │ │ │ │ ├── JITMapIndexOperator.java │ │ │ │ │ │ │ │ ├── JITMapOperator.java │ │ │ │ │ │ │ │ ├── JITNegOperator.java │ │ │ │ │ │ │ │ ├── JITOperator.java │ │ │ │ │ │ │ │ ├── JITOperatorReference.java │ │ │ │ │ │ │ │ ├── JITSinkOperator.java │ │ │ │ │ │ │ │ ├── JITSourceOperator.java │ │ │ │ │ │ │ │ ├── JITSubtractOperator.java │ │ │ │ │ │ │ │ ├── JITSumOperator.java │ │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ └── types │ │ │ │ │ │ │ │ ├── JITBoolType.java │ │ │ │ │ │ │ │ ├── JITDateType.java │ │ │ │ │ │ │ │ ├── JITF32Type.java │ │ │ │ │ │ │ │ ├── JITF64Type.java │ │ │ │ │ │ │ │ ├── JITI16Type.java │ │ │ │ │ │ │ │ ├── JITI32Type.java │ │ │ │ │ │ │ │ ├── JITI64Type.java │ │ │ │ │ │ │ │ ├── JITISizeType.java │ │ │ │ │ │ │ │ ├── JITKVType.java │ │ │ │ │ │ │ │ ├── JITRowType.java │ │ │ │ │ │ │ │ ├── JITRowTypeReference.java │ │ │ │ │ │ │ │ ├── JITScalarType.java │ │ │ │ │ │ │ │ ├── JITStringType.java │ │ │ │ │ │ │ │ ├── JITTimestampType.java │ │ │ │ │ │ │ │ ├── JITType.java │ │ │ │ │ │ │ │ ├── JITUSizeType.java │ │ │ │ │ │ │ │ ├── JITUnitType.java │ │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── optimize │ │ │ │ │ │ ├── BetaReduction.java │ │ │ │ │ │ ├── DeadCodeVisitor.java │ │ │ │ │ │ ├── ExpressionSubstitutionContext.java │ │ │ │ │ │ ├── IncrementalizeVisitor.java │ │ │ │ │ │ ├── NoIntegralVisitor.java │ │ │ │ │ │ ├── OptimizeDistinctVisitor.java │ │ │ │ │ │ ├── OptimizeIncrementalVisitor.java │ │ │ │ │ │ ├── RemoveOperatorsVisitor.java │ │ │ │ │ │ ├── Simplify.java │ │ │ │ │ │ ├── Substitution.java │ │ │ │ │ │ ├── SubstitutionContext.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── rust │ │ │ │ │ │ ├── LowerCircuitVisitor.java │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ ├── RustFileWriter.java │ │ │ │ │ │ ├── RustSqlRuntimeLibrary.java │ │ │ │ │ │ ├── ToRustHandleVisitor.java │ │ │ │ │ │ ├── ToRustInnerVisitor.java │ │ │ │ │ │ ├── ToRustVisitor.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ └── visitors │ │ │ │ │ │ ├── CircuitCloneVisitor.java │ │ │ │ │ │ ├── CircuitDelegateVisitor.java │ │ │ │ │ │ ├── CircuitFunctionRewriter.java │ │ │ │ │ │ ├── InnerExpressionRewriteVisitor.java │ │ │ │ │ │ ├── PassesVisitor.java │ │ │ │ │ │ └── package-info.java │ │ │ │ ├── errors │ │ │ │ │ ├── CompilerMessages.java │ │ │ │ │ ├── SourceFileContents.java │ │ │ │ │ ├── SourcePosition.java │ │ │ │ │ ├── SourcePositionRange.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── frontend │ │ │ │ │ ├── AggregateCompiler.java │ │ │ │ │ ├── CalciteToDBSPCompiler.java │ │ │ │ │ ├── CollectIdentifiers.java │ │ │ │ │ ├── ExpressionCompiler.java │ │ │ │ │ ├── JoinConditionAnalyzer.java │ │ │ │ │ ├── ModifyTableTranslation.java │ │ │ │ │ ├── TableContents.java │ │ │ │ │ ├── TypeCompiler.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── statements │ │ │ │ │ │ ├── CreateRelationStatement.java │ │ │ │ │ │ ├── CreateTableStatement.java │ │ │ │ │ │ ├── CreateViewStatement.java │ │ │ │ │ │ ├── DropTableStatement.java │ │ │ │ │ │ ├── FrontEndStatement.java │ │ │ │ │ │ ├── TableModifyStatement.java │ │ │ │ │ │ └── package-info.java │ │ │ │ ├── optimizer │ │ │ │ │ └── CircuitOptimizer.java │ │ │ │ ├── package-info.java │ │ │ │ └── sqlparser │ │ │ │ │ ├── CalciteCompiler.java │ │ │ │ │ ├── Catalog.java │ │ │ │ │ └── package-info.java │ │ │ ├── ir │ │ │ │ ├── CircuitVisitor.java │ │ │ │ ├── DBSPAggregate.java │ │ │ │ ├── DBSPFunction.java │ │ │ │ ├── DBSPParameter.java │ │ │ │ ├── InnerVisitor.java │ │ │ │ ├── expression │ │ │ │ │ ├── DBSPApplyExpression.java │ │ │ │ │ ├── DBSPApplyMethodExpression.java │ │ │ │ │ ├── DBSPAsExpression.java │ │ │ │ │ ├── DBSPAssignmentExpression.java │ │ │ │ │ ├── DBSPBaseTupleExpression.java │ │ │ │ │ ├── DBSPBinaryExpression.java │ │ │ │ │ ├── DBSPBlockExpression.java │ │ │ │ │ ├── DBSPBorrowExpression.java │ │ │ │ │ ├── DBSPCastExpression.java │ │ │ │ │ ├── DBSPClosureExpression.java │ │ │ │ │ ├── DBSPComparatorExpression.java │ │ │ │ │ ├── DBSPDerefExpression.java │ │ │ │ │ ├── DBSPEnumValue.java │ │ │ │ │ ├── DBSPExpression.java │ │ │ │ │ ├── DBSPFieldComparatorExpression.java │ │ │ │ │ ├── DBSPFieldExpression.java │ │ │ │ │ ├── DBSPFlatmap.java │ │ │ │ │ ├── DBSPForExpression.java │ │ │ │ │ ├── DBSPIfExpression.java │ │ │ │ │ ├── DBSPIndexExpression.java │ │ │ │ │ ├── DBSPMatchExpression.java │ │ │ │ │ ├── DBSPNoComparatorExpression.java │ │ │ │ │ ├── DBSPPathExpression.java │ │ │ │ │ ├── DBSPQualifyTypeExpression.java │ │ │ │ │ ├── DBSPRangeExpression.java │ │ │ │ │ ├── DBSPRawTupleExpression.java │ │ │ │ │ ├── DBSPSortExpression.java │ │ │ │ │ ├── DBSPStructExpression.java │ │ │ │ │ ├── DBSPTupleExpression.java │ │ │ │ │ ├── DBSPUnaryExpression.java │ │ │ │ │ ├── DBSPVariablePath.java │ │ │ │ │ ├── IDBSPContainer.java │ │ │ │ │ ├── literal │ │ │ │ │ │ ├── DBSPBoolLiteral.java │ │ │ │ │ │ ├── DBSPCloneExpression.java │ │ │ │ │ │ ├── DBSPDateLiteral.java │ │ │ │ │ │ ├── DBSPDecimalLiteral.java │ │ │ │ │ │ ├── DBSPDoubleLiteral.java │ │ │ │ │ │ ├── DBSPFloatLiteral.java │ │ │ │ │ │ ├── DBSPGeoPointLiteral.java │ │ │ │ │ │ ├── DBSPI32Literal.java │ │ │ │ │ │ ├── DBSPI64Literal.java │ │ │ │ │ │ ├── DBSPISizeLiteral.java │ │ │ │ │ │ ├── DBSPIntervalLiteral.java │ │ │ │ │ │ ├── DBSPIntervalMillisLiteral.java │ │ │ │ │ │ ├── DBSPIntervalMonthsLiteral.java │ │ │ │ │ │ ├── DBSPIsNullExpression.java │ │ │ │ │ │ ├── DBSPKeywordLiteral.java │ │ │ │ │ │ ├── DBSPLiteral.java │ │ │ │ │ │ ├── DBSPStrLiteral.java │ │ │ │ │ │ ├── DBSPStringLiteral.java │ │ │ │ │ │ ├── DBSPTimeLiteral.java │ │ │ │ │ │ ├── DBSPTimestampLiteral.java │ │ │ │ │ │ ├── DBSPU32Literal.java │ │ │ │ │ │ ├── DBSPU64Literal.java │ │ │ │ │ │ ├── DBSPUSizeLiteral.java │ │ │ │ │ │ ├── DBSPVecLiteral.java │ │ │ │ │ │ ├── DBSPZSetLiteral.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ ├── path │ │ │ │ │ ├── DBSPPath.java │ │ │ │ │ ├── DBSPPathSegment.java │ │ │ │ │ ├── DBSPSimplePathSegment.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── pattern │ │ │ │ │ ├── DBSPIdentifierPattern.java │ │ │ │ │ ├── DBSPLiteralPattern.java │ │ │ │ │ ├── DBSPPattern.java │ │ │ │ │ ├── DBSPRefPattern.java │ │ │ │ │ ├── DBSPTuplePattern.java │ │ │ │ │ ├── DBSPTupleStructPattern.java │ │ │ │ │ ├── DBSPWildcardPattern.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── statement │ │ │ │ │ ├── DBSPExpressionStatement.java │ │ │ │ │ ├── DBSPLetStatement.java │ │ │ │ │ ├── DBSPStatement.java │ │ │ │ │ └── package-info.java │ │ │ │ └── type │ │ │ │ │ ├── DBSPType.java │ │ │ │ │ ├── DBSPTypeAny.java │ │ │ │ │ ├── DBSPTypeFunction.java │ │ │ │ │ ├── DBSPTypeIndexedZSet.java │ │ │ │ │ ├── DBSPTypeRawTuple.java │ │ │ │ │ ├── DBSPTypeRef.java │ │ │ │ │ ├── DBSPTypeSemigroup.java │ │ │ │ │ ├── DBSPTypeStream.java │ │ │ │ │ ├── DBSPTypeStruct.java │ │ │ │ │ ├── DBSPTypeTuple.java │ │ │ │ │ ├── DBSPTypeTupleBase.java │ │ │ │ │ ├── DBSPTypeUser.java │ │ │ │ │ ├── DBSPTypeVec.java │ │ │ │ │ ├── DBSPTypeZSet.java │ │ │ │ │ ├── ICollectionType.java │ │ │ │ │ ├── IHasType.java │ │ │ │ │ ├── IsDateType.java │ │ │ │ │ ├── IsNumericType.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── primitive │ │ │ │ │ ├── DBSPTypeBaseType.java │ │ │ │ │ ├── DBSPTypeBool.java │ │ │ │ │ ├── DBSPTypeDate.java │ │ │ │ │ ├── DBSPTypeDecimal.java │ │ │ │ │ ├── DBSPTypeDouble.java │ │ │ │ │ ├── DBSPTypeFP.java │ │ │ │ │ ├── DBSPTypeFloat.java │ │ │ │ │ ├── DBSPTypeGeo.java │ │ │ │ │ ├── DBSPTypeGeoPoint.java │ │ │ │ │ ├── DBSPTypeISize.java │ │ │ │ │ ├── DBSPTypeInteger.java │ │ │ │ │ ├── DBSPTypeKeyword.java │ │ │ │ │ ├── DBSPTypeMillisInterval.java │ │ │ │ │ ├── DBSPTypeMonthsInterval.java │ │ │ │ │ ├── DBSPTypeNull.java │ │ │ │ │ ├── DBSPTypeStr.java │ │ │ │ │ ├── DBSPTypeString.java │ │ │ │ │ ├── DBSPTypeTime.java │ │ │ │ │ ├── DBSPTypeTimestamp.java │ │ │ │ │ ├── DBSPTypeUSize.java │ │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ │ ├── sqllogictest │ │ │ ├── AcceptancePolicy.java │ │ │ ├── ExecutionOptions.java │ │ │ ├── ISqlTestOperation.java │ │ │ ├── Main.java │ │ │ ├── README.md │ │ │ ├── SLTTestFile.java │ │ │ ├── SqlStatement.java │ │ │ ├── SqlStatementList.java │ │ │ ├── SqlTestPrepareInput.java │ │ │ ├── SqlTestPrepareTables.java │ │ │ ├── SqlTestPrepareViews.java │ │ │ ├── SqlTestQuery.java │ │ │ ├── SqlTestQueryOutputDescription.java │ │ │ ├── executors │ │ │ │ ├── CalciteExecutor.java │ │ │ │ ├── DBSPExecutor.java │ │ │ │ ├── DBSP_JDBC_Executor.java │ │ │ │ ├── JDBCExecutor.java │ │ │ │ ├── NoExecutor.java │ │ │ │ ├── SqlSLTTestExecutor.java │ │ │ │ ├── SqlTestExecutor.java │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ │ └── util │ │ │ ├── FieldsAreNonnullByDefault.java │ │ │ ├── FreshName.java │ │ │ ├── ICastable.java │ │ │ ├── IDebuggable.java │ │ │ ├── IHasName.java │ │ │ ├── IIndentStream.java │ │ │ ├── IModule.java │ │ │ ├── IdGen.java │ │ │ ├── IndentStream.java │ │ │ ├── Linq.java │ │ │ ├── Logger.java │ │ │ ├── MethodsAreNonnullByDefault.java │ │ │ ├── NameGen.java │ │ │ ├── SqlLexicalRulesConverter.java │ │ │ ├── StringPrintStream.java │ │ │ ├── TestStatistics.java │ │ │ ├── ToIndentableString.java │ │ │ ├── TranslationException.java │ │ │ ├── Unimplemented.java │ │ │ ├── UnsupportedException.java │ │ │ ├── Utilities.java │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── org │ │ └── dbsp │ │ └── sqlCompiler │ │ └── compiler │ │ ├── ArrayTests.java │ │ ├── BaseSQLTests.java │ │ ├── CalciteCompilerTests.java │ │ ├── CastTests.java │ │ ├── ComplexQueriesTest.java │ │ ├── DBSPCompilerTests.java │ │ ├── EndToEndTests.java │ │ ├── MultiViewTests.java │ │ ├── NaiveIncrementalTests.java │ │ ├── NexmarkTest.java │ │ ├── OptimizedIncrementalTests.java │ │ ├── OtherTests.java │ │ ├── TimeTests.java │ │ ├── package-info.java │ │ └── postgres │ │ ├── PostgresDateTests.java │ │ ├── PostgresNumericTests.java │ │ ├── PostgresTimestampTests.java │ │ ├── README.md │ │ └── package-info.java └── x.sql ├── doc ├── .gitignore ├── Makefile ├── README.rst ├── VERSION ├── _static │ └── css │ │ └── rtd_theme_mods.css ├── conf.py ├── dict.txt ├── index.rst ├── intro.rst ├── requirements.txt ├── sql.rst ├── sql │ ├── array.rst │ ├── boolean.rst │ ├── comparisons.rst │ ├── datetime.rst │ ├── decimal.rst │ ├── float.rst │ ├── fp.rst │ ├── integer.rst │ ├── string.rst │ ├── structure.rst │ └── types.rst └── styles │ ├── epub.css │ ├── pdf.css │ └── website.css ├── lib ├── genlib │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── lib.rs ├── hashing │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── readers │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ └── test.csv ├── sqllib │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── casts.rs │ │ ├── geopoint.rs │ │ ├── interval.rs │ │ ├── lib.rs │ │ └── timestamp.rs ├── sqlvalue │ ├── Cargo.toml │ └── src │ │ └── lib.rs └── tuple │ ├── Cargo.toml │ ├── README.md │ └── src │ └── lib.rs └── temp ├── .gitignore ├── Cargo.toml └── src └── README.md /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | tests: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | java: ['8', '11'] 11 | 12 | name: Tests (Java ${{ matrix.java }}) 13 | 14 | steps: 15 | - name: Skip Duplicate Actions 16 | uses: fkirc/skip-duplicate-actions@v5.3.0 17 | 18 | - uses: actions/checkout@v2 19 | 20 | - name: Set up JDK {{ matrix.java }} 21 | uses: actions/setup-java@v2 22 | with: 23 | java-version: ${{ matrix.java }} 24 | distribution: 'adopt' 25 | 26 | - name: Install rust 27 | uses: actions-rs/toolchain@v1 28 | with: 29 | toolchain: stable 30 | profile: minimal 31 | default: true 32 | 33 | - name: Setup Graphviz 34 | uses: ts-graphviz/setup-graphviz@v1 35 | 36 | - name: Build with Maven 37 | run: cd SQL-compiler && mvn --batch-mode package 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | SQL-compiler/target/ 26 | SQL-compiler/.idea/ 27 | # Compiler-generated test files 28 | temp/ 29 | lib/*/target/ 30 | # Generated by ANTLR 31 | *.tokens 32 | .idea 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | SQL to Database Stream Processor Compiler 2 | Copyright 2022 VMware, Inc. 3 | 4 | The MIT license (the "License") set forth below applies to all parts of the SQL to Database Stream Processor Compiler project. You may not use this file except in compliance with the License. 5 | 6 | MIT License 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | 15 | 16 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | SQL to Database Stream Processor Compiler 2 | Copyright 2022 VMware, Inc. 3 | 4 | This product is licensed to you under the MIT license (the "License"). You may not use this product except in compliance with the MIT License. 5 | 6 | This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. 7 | 8 | -------------------------------------------------------------------------------- /SQL-compiler/compile-jit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FILE=$1 4 | cd ../../database-stream-processor 5 | FILEPATH=../sql-to-dbsp-compiler/SQL-compiler/${FILE} 6 | cargo run -p dataflow-jit --bin dataflow-jit --features binary -- ${FILEPATH} 7 | #cargo run -p dataflow-jit --features binary -- --print-schema ${FILEPATH} 8 | -------------------------------------------------------------------------------- /SQL-compiler/psqlsltbugs.txt: -------------------------------------------------------------------------------- 1 | // This file contains a list of SqlLogicTest which I believe are 2 | // buggy when using Postgres. Each line is a statement or query that 3 | // is buggy, without newlines. Lines starting with // are ignored. 4 | INSERT OR REPLACE INTO t1 VALUES(2, 'insert or replace') 5 | // Expected to fail 6 | REPLACE INTO t1 VALUES(2, 'replace') 7 | // Expected to pass 8 | -------------------------------------------------------------------------------- /SQL-compiler/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | pushd ../temp; cargo update; popd 6 | 7 | if [ ! -d ../../sqllogictest ]; then 8 | echo "I expected that the SQL logic tests are installed in ../../" 9 | echo "You can do that using 'git clone https://github.com/gregrahn/sqllogictest.git'" 10 | exit 1 11 | fi 12 | 13 | mvn clean 14 | mvn -DskipTests package 15 | mvn test 16 | echo "Running sqllogictest tests" 17 | mvn compile exec:java -Dexec.mainClass="org.dbsp.sqllogictest.Main" -Dexec.args="-inc -i -s -e hybrid -d ../../sqllogictest/ ." 18 | -------------------------------------------------------------------------------- /SQL-compiler/sql-to-dbsp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | 5 | java -jar ${THIS_DIR}/target/sql-to-dbsp-jar-with-dependencies.jar $* 6 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/README: -------------------------------------------------------------------------------- 1 | This directory contains the IR representation of DBSP circuits -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/circuit/IDBSPDeclaration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.circuit; 25 | 26 | public interface IDBSPDeclaration extends IDBSPInnerNode, IDBSPOuterNode { 27 | String getName(); 28 | } 29 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/circuit/IDBSPInnerNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.circuit; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | /** 29 | * IR modes from the inner language: expressions, types, etc. 30 | */ 31 | public interface IDBSPInnerNode extends IDBSPNode { 32 | void accept(InnerVisitor visitor); 33 | } 34 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/circuit/IDBSPOuterNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.circuit; 25 | 26 | import org.dbsp.sqlCompiler.ir.CircuitVisitor; 27 | 28 | /** 29 | * IR modes from the outer language: circuits and operators. 30 | */ 31 | public interface IDBSPOuterNode extends IDBSPNode { 32 | void accept(CircuitVisitor visitor); 33 | } 34 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/circuit/operator/DBSPAggregateOperatorBase.java: -------------------------------------------------------------------------------- 1 | package org.dbsp.sqlCompiler.circuit.operator; 2 | 3 | import org.dbsp.sqlCompiler.ir.DBSPAggregate; 4 | import org.dbsp.sqlCompiler.ir.expression.DBSPExpression; 5 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 6 | 7 | import javax.annotation.Nullable; 8 | import java.util.Objects; 9 | 10 | /** 11 | * Base class for operators that perform some form of aggregation. 12 | */ 13 | public abstract class DBSPAggregateOperatorBase extends DBSPUnaryOperator { 14 | @Nullable 15 | public final DBSPAggregate aggregate; 16 | 17 | protected DBSPAggregateOperatorBase(@Nullable Object node, String operation, DBSPType outputType, 18 | @Nullable DBSPExpression function, 19 | @Nullable DBSPAggregate aggregate, 20 | boolean multiset, 21 | DBSPOperator source) { 22 | super(node, operation, function, outputType, multiset, source); 23 | this.aggregate = aggregate; 24 | // There are really two different representations of an aggregate operator, 25 | // which reuse the same classes: a high-level one, which contains an Aggregate, 26 | // and a low-level one, which contains a function. 27 | if (aggregate == null) { 28 | if (function == null) 29 | throw new RuntimeException("'function' and 'aggregate' are both null"); 30 | } else { 31 | if (function != null) 32 | throw new RuntimeException("'function' and 'aggregate' are both non-null"); 33 | } 34 | } 35 | 36 | public DBSPAggregate getAggregate() { 37 | return Objects.requireNonNull(this.aggregate); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/circuit/operator/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.circuit.operator; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/circuit/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.circuit; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/ICompilerComponent.java: -------------------------------------------------------------------------------- 1 | package org.dbsp.sqlCompiler.compiler; 2 | 3 | import org.dbsp.sqlCompiler.compiler.backend.DBSPCompiler; 4 | 5 | public interface ICompilerComponent { 6 | DBSPCompiler getCompiler(); 7 | } 8 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/README.md: -------------------------------------------------------------------------------- 1 | A compiler that translated SQL to DBSP circuits 2 | 3 | The frontend uses Calcite to parse SQL. 4 | It is done in three phases: 5 | 6 | - Parse SQL to SqlNode 7 | - Convert SqlNode to RelNode 8 | - Optimize RelNode 9 | 10 | The midend converts RelNode to a circuit IR -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/IJITId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir; 25 | 26 | /** 27 | * Interface implemented by JIT objects that have a numeric id. 28 | */ 29 | public interface IJITId { 30 | long getId(); 31 | JITReference getReference(); 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/cfg/JITBlockDestination.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.cfg; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITNode; 27 | 28 | /** 29 | * When jumping to a new block one has to specify both 30 | * the target block and the arguments to be bound to the parameters. 31 | */ 32 | public class JITBlockDestination extends JITNode { 33 | final JITBlockReference target; 34 | final JITBlockArguments arguments; 35 | 36 | public JITBlockDestination(JITBlockReference target, JITBlockArguments arguments) { 37 | this.target = target; 38 | this.arguments = arguments; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/cfg/JITBlockReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.cfg; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITReference; 27 | 28 | public class JITBlockReference extends JITReference { 29 | public JITBlockReference(long id) { 30 | super(id); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/cfg/JITBlockTerminator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.cfg; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITNode; 27 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.instructions.JITInstructionReference; 28 | 29 | public abstract class JITBlockTerminator extends JITNode { 30 | // These are called 'parameters' in Rust, but they really are arguments. 31 | final JITBlockArguments arguments; 32 | 33 | protected JITBlockTerminator() { 34 | this.arguments = new JITBlockArguments(); 35 | } 36 | 37 | public void addArgument(JITInstructionReference arg) { 38 | this.arguments.addArgument(arg); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/cfg/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.cfg; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/instructions/JITInstructionReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.instructions; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITReference; 27 | 28 | /** 29 | * Refers to another instruction by its id. 30 | */ 31 | public class JITInstructionReference extends JITReference { 32 | public JITInstructionReference(long id) { 33 | super(id); 34 | } 35 | 36 | /** 37 | * Creates an invalid instruction reference. 38 | */ 39 | public JITInstructionReference() { 40 | super(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/instructions/JITUninitRowInstruction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.instructions; 25 | 26 | import com.fasterxml.jackson.databind.node.BaseJsonNode; 27 | import com.fasterxml.jackson.databind.node.ObjectNode; 28 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 29 | 30 | public class JITUninitRowInstruction extends JITInstruction { 31 | public final JITRowType type; 32 | 33 | public JITUninitRowInstruction(long id, JITRowType type) { 34 | super(id, "UninitRow"); 35 | this.type = type; 36 | } 37 | 38 | @Override 39 | protected BaseJsonNode instructionAsJson() { 40 | ObjectNode result = jsonFactory().createObjectNode(); 41 | result.put("layout", this.type.getId()); 42 | return result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/instructions/JITValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.instructions; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITNode; 27 | 28 | /** 29 | * Base class for various (compile-time constant) values. 30 | */ 31 | public abstract class JITValue extends JITNode { } 32 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/instructions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.instructions; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITDifferentiateOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 27 | 28 | import java.util.List; 29 | 30 | public class JITDifferentiateOperator extends JITOperator { 31 | public JITDifferentiateOperator(long id, JITRowType type, List inputs) { 32 | super(id, "Differentiate", "", type, inputs, null, null); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITDistinctOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITFunction; 27 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 28 | 29 | import java.util.List; 30 | 31 | public class JITDistinctOperator extends JITOperator { 32 | public JITDistinctOperator(long id, JITRowType type, List inputs) { 33 | super(id, "Distinct", "", type, inputs, null, null); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITFilterOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import com.fasterxml.jackson.databind.node.BaseJsonNode; 27 | import com.fasterxml.jackson.databind.node.ObjectNode; 28 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITFunction; 29 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 30 | import org.dbsp.util.Linq; 31 | 32 | import java.util.List; 33 | 34 | public class JITFilterOperator extends JITOperator { 35 | public JITFilterOperator(long id, JITRowType type, List inputs, JITFunction function) { 36 | super(id, "Filter", "filter_fn", type, inputs, function, null); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITFlatMapOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 27 | 28 | import java.util.List; 29 | 30 | public class JITFlatMapOperator extends JITOperator { 31 | public JITFlatMapOperator(long id, JITRowType type, List inputs) { 32 | super(id, "FlatMap", "flat_map", type, inputs, null, null); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITIntegrateOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 27 | 28 | import java.util.List; 29 | 30 | public class JITIntegrateOperator extends JITOperator { 31 | public JITIntegrateOperator(long id, JITRowType type, List inputs) { 32 | super(id, "Integrate", "", type, inputs, null, null); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITOperatorReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITReference; 27 | import org.dbsp.util.IIndentStream; 28 | 29 | /** 30 | * Refers to another operator by its id. 31 | */ 32 | public class JITOperatorReference extends JITReference { 33 | public JITOperatorReference(long id) { 34 | super(id); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITSinkOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 27 | 28 | import java.util.List; 29 | 30 | public class JITSinkOperator extends JITOperator { 31 | public JITSinkOperator(long id, JITRowType type, List inputs, String comment) { 32 | super(id, "Sink", "", type, inputs, null, comment); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/JITSubtractOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.types.JITRowType; 27 | 28 | import java.util.List; 29 | 30 | public class JITSubtractOperator extends JITOperator { 31 | public JITSubtractOperator(long id, JITRowType type, List inputs) { 32 | super(id, "Minus", "", type, inputs, null, null); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/operators/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.operators; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITBoolType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITBoolType extends JITScalarType { 27 | public static JITBoolType INSTANCE = new JITBoolType(); 28 | 29 | protected JITBoolType() { 30 | super("Bool"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITDateType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITDateType extends JITScalarType { 27 | public static JITDateType INSTANCE = new JITDateType(); 28 | 29 | protected JITDateType() { 30 | super("Date"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITF32Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITF32Type extends JITScalarType { 27 | public static JITF32Type INSTANCE = new JITF32Type(); 28 | 29 | protected JITF32Type() { 30 | super("F32"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITF64Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITF64Type extends JITScalarType { 27 | public static JITF64Type INSTANCE = new JITF64Type(); 28 | 29 | protected JITF64Type() { 30 | super("F64"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITI16Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITI16Type extends JITScalarType { 27 | public static JITI16Type INSTANCE = new JITI16Type(); 28 | 29 | protected JITI16Type() { 30 | super("I16"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITI32Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITI32Type extends JITScalarType { 27 | public static JITI32Type INSTANCE = new JITI32Type(); 28 | 29 | protected JITI32Type() { 30 | super("I32"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITI64Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITI64Type extends JITScalarType { 27 | public static JITI64Type INSTANCE = new JITI64Type(); 28 | 29 | protected JITI64Type() { 30 | super("I64"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITISizeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITISizeType extends JITScalarType { 27 | public static JITISizeType INSTANCE = new JITISizeType(); 28 | 29 | protected JITISizeType() { 30 | super("Isize"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITKVType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | import com.fasterxml.jackson.databind.node.BaseJsonNode; 27 | 28 | /** 29 | * A pair type with two fields: a key type and a value type. 30 | */ 31 | public class JITKVType extends JITType { 32 | final JITRowType key; 33 | final JITRowType value; 34 | 35 | public JITKVType(JITRowType key, JITRowType value) { 36 | this.key = key; 37 | this.value = value; 38 | } 39 | 40 | @Override 41 | public BaseJsonNode asJson() { 42 | return super.asJson(); 43 | } 44 | 45 | @Override 46 | public boolean isScalarType() { 47 | return false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITRowTypeReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITReference; 27 | 28 | public class JITRowTypeReference extends JITReference { 29 | public JITRowTypeReference(long id) { 30 | super(id); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITStringType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITStringType extends JITScalarType { 27 | public static JITStringType INSTANCE = new JITStringType(); 28 | 29 | protected JITStringType() { 30 | super("String"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITTimestampType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITTimestampType extends JITScalarType { 27 | public static JITTimestampType INSTANCE = new JITTimestampType(); 28 | 29 | protected JITTimestampType() { 30 | super("Timestamp"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | import org.dbsp.sqlCompiler.compiler.backend.jit.ir.JITNode; 27 | import org.dbsp.util.IIndentStream; 28 | 29 | public abstract class JITType extends JITNode { 30 | protected JITType() {} 31 | public abstract boolean isScalarType(); 32 | 33 | @Override 34 | public IIndentStream toString(IIndentStream builder) { 35 | return builder.append(this.toString()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITUSizeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITUSizeType extends JITScalarType { 27 | public static JITUSizeType INSTANCE = new JITUSizeType(); 28 | 29 | protected JITUSizeType() { 30 | super("Usize"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/JITUnitType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 25 | 26 | public class JITUnitType extends JITScalarType { 27 | public static JITUnitType INSTANCE = new JITUnitType(); 28 | 29 | protected JITUnitType() { 30 | super("Unit"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/ir/types/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.jit.ir.types; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/jit/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.jit; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/optimize/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.optimize; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/rust/README.md: -------------------------------------------------------------------------------- 1 | This directory contains code related to Rust code generation. 2 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/rust/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.rust; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/visitors/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.backend.visitors; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/errors/SourcePosition.java: -------------------------------------------------------------------------------- 1 | package org.dbsp.sqlCompiler.compiler.errors; 2 | 3 | class SourcePosition { 4 | public static final SourcePosition INVALID = new SourcePosition(0, 0); 5 | 6 | public final int line; // Numbered from 1 7 | public final int column; // Numbered from 1 8 | 9 | SourcePosition(int line, int column) { 10 | this.line = line; 11 | this.column = column; 12 | } 13 | 14 | boolean isValid() { 15 | return this.line > 0 && this.column > 0; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return this.line + ":" + this.column; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/errors/SourcePositionRange.java: -------------------------------------------------------------------------------- 1 | package org.dbsp.sqlCompiler.compiler.errors; 2 | 3 | import org.apache.calcite.sql.parser.SqlParserPos; 4 | 5 | /** 6 | * A range of characters inside the source code. 7 | */ 8 | public class SourcePositionRange { 9 | public final SourcePosition start; 10 | public final SourcePosition end; 11 | 12 | public static final SourcePositionRange INVALID = 13 | new SourcePositionRange(SourcePosition.INVALID, SourcePosition.INVALID); 14 | 15 | public SourcePositionRange(SourcePosition start, SourcePosition end) { 16 | this.start = start; 17 | this.end = end; 18 | } 19 | 20 | public SourcePositionRange(SqlParserPos pos) { 21 | this.start = new SourcePosition(pos.getLineNum(), pos.getColumnNum()); 22 | this.end = new SourcePosition(pos.getEndLineNum(), pos.getEndColumnNum()); 23 | } 24 | 25 | public boolean isValid() { 26 | return this.start.isValid() && this.end.isValid(); 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return this.start + "--" + this.end; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/errors/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.errors; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.frontend; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/statements/CreateTableStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.frontend.statements; 25 | 26 | import com.fasterxml.jackson.databind.JsonNode; 27 | import org.apache.calcite.rel.type.RelDataTypeField; 28 | import org.apache.calcite.sql.SqlNode; 29 | 30 | import javax.annotation.Nullable; 31 | import java.util.List; 32 | 33 | /** 34 | * Describes a table as produced by a CREATE TABLE DDL statement. 35 | */ 36 | public class CreateTableStatement extends CreateRelationStatement { 37 | public CreateTableStatement(@Nullable SqlNode node, String statement, String tableName, @Nullable String comment, List columns) { 38 | super(node, statement, tableName, comment, columns); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/statements/DropTableStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler.frontend.statements; 25 | 26 | import org.apache.calcite.sql.SqlNode; 27 | 28 | import javax.annotation.Nullable; 29 | 30 | public class DropTableStatement extends FrontEndStatement { 31 | public final String tableName; 32 | 33 | public DropTableStatement(@Nullable SqlNode node, String statement, 34 | String tableName, @Nullable String comment) { 35 | super(node, statement, comment); 36 | this.tableName = tableName; 37 | } 38 | 39 | @Nullable 40 | @Override 41 | public SqlNode getNode() { 42 | return this.node; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/statements/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.frontend.statements; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/sqlparser/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.compiler.sqlparser; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/DBSPAsExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 28 | 29 | public class DBSPAsExpression extends DBSPExpression { 30 | public final DBSPExpression source; 31 | 32 | public DBSPAsExpression(DBSPExpression source, DBSPType type) { 33 | super(null, type); 34 | this.source = source; 35 | } 36 | 37 | @Override 38 | public void accept(InnerVisitor visitor) { 39 | if (!visitor.preorder(this)) return; 40 | this.source.accept(visitor); 41 | if (this.type != null) 42 | this.type.accept(visitor); 43 | visitor.postorder(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/DBSPAssignmentExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | public class DBSPAssignmentExpression extends DBSPExpression { 29 | public final DBSPExpression left; 30 | public final DBSPExpression right; 31 | 32 | public DBSPAssignmentExpression(DBSPExpression left, DBSPExpression right) { 33 | super(null, null); 34 | this.left = left; 35 | this.right = right; 36 | } 37 | 38 | @Override 39 | public void accept(InnerVisitor visitor) { 40 | if (!visitor.preorder(this)) return; 41 | if (this.type != null) 42 | this.type.accept(visitor); 43 | this.left.accept(visitor); 44 | this.right.accept(visitor); 45 | visitor.postorder(this); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/DBSPBaseTupleExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 27 | 28 | import javax.annotation.Nullable; 29 | 30 | public abstract class DBSPBaseTupleExpression extends DBSPExpression { 31 | public final DBSPExpression[] fields; 32 | 33 | public int size() { return this.fields.length; } 34 | 35 | public DBSPBaseTupleExpression(@Nullable Object object, DBSPType type, DBSPExpression... expressions) { 36 | super(object, type); 37 | this.fields = expressions; 38 | } 39 | 40 | public DBSPExpression get(int index) { 41 | return this.fields[index]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/DBSPDerefExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | /** 29 | * An expression of the form *expression. 30 | */ 31 | public class DBSPDerefExpression extends DBSPExpression { 32 | public final DBSPExpression expression; 33 | 34 | public DBSPDerefExpression(DBSPExpression expression) { 35 | super(null, expression.getNonVoidType().deref()); 36 | this.expression = expression; 37 | } 38 | 39 | @Override 40 | public void accept(InnerVisitor visitor) { 41 | if (!visitor.preorder(this)) return; 42 | if (this.type != null) 43 | this.type.accept(visitor); 44 | this.expression.accept(visitor); 45 | visitor.postorder(this); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/DBSPNoComparatorExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 27 | 28 | import javax.annotation.Nullable; 29 | 30 | /** 31 | * A comparator that does not compare any fields. 32 | */ 33 | public class DBSPNoComparatorExpression extends DBSPComparatorExpression { 34 | public final DBSPType tupleType; 35 | 36 | public DBSPNoComparatorExpression(@Nullable Object node, DBSPType tupleType) { 37 | super(node); 38 | this.tupleType = tupleType; 39 | } 40 | 41 | @Override 42 | public DBSPType tupleType() { 43 | return this.tupleType; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/DBSPPathExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | import org.dbsp.sqlCompiler.ir.path.DBSPPath; 28 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 29 | 30 | public class DBSPPathExpression extends DBSPExpression { 31 | public final DBSPPath path; 32 | 33 | public DBSPPathExpression(DBSPType type, DBSPPath path) { 34 | super(null, type); 35 | this.path = path; 36 | } 37 | 38 | @Override 39 | public void accept(InnerVisitor visitor) { 40 | if (!visitor.preorder(this)) return; 41 | if (this.type != null) 42 | this.type.accept(visitor); 43 | this.path.accept(visitor); 44 | visitor.postorder(this); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/IDBSPContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression; 25 | 26 | public interface IDBSPContainer { 27 | void add(DBSPExpression expression); 28 | } 29 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/literal/DBSPDecimalLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression.literal; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 28 | 29 | import javax.annotation.Nullable; 30 | import java.math.BigDecimal; 31 | 32 | public class DBSPDecimalLiteral extends DBSPLiteral { 33 | @Nullable 34 | public final BigDecimal value; 35 | 36 | public DBSPDecimalLiteral(@Nullable Object node, DBSPType type, @Nullable BigDecimal value) { 37 | super(node, type, value); 38 | this.value = value; 39 | } 40 | 41 | @Override 42 | public void accept(InnerVisitor visitor) { 43 | if (!visitor.preorder(this)) return; 44 | visitor.postorder(this); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/literal/DBSPIntervalLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.expression.literal; 25 | 26 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 27 | import org.dbsp.sqlCompiler.ir.type.primitive.DBSPTypeMillisInterval; 28 | 29 | import javax.annotation.Nullable; 30 | 31 | public class DBSPIntervalLiteral extends DBSPLiteral { 32 | public DBSPIntervalLiteral(@Nullable Object node, DBSPType type, @Nullable Object value) { 33 | super(node, type, value); 34 | if (!type.is(DBSPTypeMillisInterval.class)) 35 | throw new RuntimeException("Type is not an interval " + type); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/literal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.expression.literal; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/expression/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.expression; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/path/DBSPPathSegment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.path; 25 | 26 | import org.dbsp.sqlCompiler.circuit.DBSPNode; 27 | import org.dbsp.sqlCompiler.circuit.IDBSPInnerNode; 28 | 29 | import javax.annotation.Nullable; 30 | 31 | public abstract class DBSPPathSegment extends DBSPNode implements IDBSPInnerNode { 32 | protected DBSPPathSegment(@Nullable Object node) { 33 | super(node); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/path/DBSPSimplePathSegment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.path; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | import org.dbsp.sqlCompiler.ir.type.DBSPType; 28 | 29 | public class DBSPSimplePathSegment extends DBSPPathSegment { 30 | public final String identifier; 31 | public final DBSPType[] genericArgs; 32 | 33 | public DBSPSimplePathSegment(String identifier, DBSPType... genericArgs) { 34 | super(null); 35 | this.identifier = identifier; 36 | this.genericArgs = genericArgs; 37 | } 38 | 39 | @Override 40 | public void accept(InnerVisitor visitor) { 41 | if (!visitor.preorder(this)) return; 42 | for (DBSPType arg: this.genericArgs) 43 | arg.accept(visitor); 44 | visitor.postorder(this); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/path/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.path; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/DBSPIdentifierPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.pattern; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | public class DBSPIdentifierPattern extends DBSPPattern { 29 | public final String identifier; 30 | public final boolean mutable; 31 | 32 | public DBSPIdentifierPattern(String identifier, boolean mutable) { 33 | super(null); 34 | this.identifier = identifier; 35 | this.mutable = mutable; 36 | } 37 | 38 | public DBSPIdentifierPattern(String identifier) { 39 | this(identifier, false); 40 | } 41 | 42 | @Override 43 | public void accept(InnerVisitor visitor) { 44 | if (!visitor.preorder(this)) return; 45 | visitor.postorder(this); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/DBSPLiteralPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.pattern; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | import org.dbsp.sqlCompiler.ir.expression.literal.DBSPLiteral; 28 | 29 | public class DBSPLiteralPattern extends DBSPPattern { 30 | public final DBSPLiteral literal; 31 | 32 | public DBSPLiteralPattern(DBSPLiteral literal) { 33 | super(literal.getNode()); 34 | this.literal = literal; 35 | } 36 | 37 | @Override 38 | public void accept(InnerVisitor visitor) { 39 | if (!visitor.preorder(this)) return; 40 | this.literal.accept(visitor); 41 | visitor.postorder(this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/DBSPPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.pattern; 25 | 26 | import org.dbsp.sqlCompiler.circuit.DBSPNode; 27 | import org.dbsp.sqlCompiler.circuit.IDBSPInnerNode; 28 | 29 | import javax.annotation.Nullable; 30 | 31 | public abstract class DBSPPattern extends DBSPNode implements IDBSPInnerNode { 32 | protected DBSPPattern(@Nullable Object node) { 33 | super(node); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/DBSPRefPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.pattern; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | public class DBSPRefPattern extends DBSPPattern { 29 | public final DBSPPattern pattern; 30 | public final boolean mutable; 31 | 32 | public DBSPRefPattern(DBSPPattern pattern, boolean mutable) { 33 | super(null); 34 | this.pattern = pattern; 35 | this.mutable = mutable; 36 | } 37 | 38 | public DBSPRefPattern(DBSPPattern pattern) { 39 | this(pattern, false); 40 | } 41 | 42 | @Override 43 | public void accept(InnerVisitor visitor) { 44 | if (!visitor.preorder(this)) return; 45 | this.pattern.accept(visitor); 46 | visitor.postorder(this); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/DBSPTuplePattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.pattern; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | public class DBSPTuplePattern extends DBSPPattern { 29 | public final DBSPPattern[] fields; 30 | 31 | public DBSPTuplePattern(DBSPPattern... fields) { 32 | super(null); 33 | this.fields = fields; 34 | } 35 | 36 | @Override 37 | public void accept(InnerVisitor visitor) { 38 | if (!visitor.preorder(this)) return; 39 | for (DBSPPattern pattern: this.fields) 40 | pattern.accept(visitor); 41 | visitor.postorder(this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/DBSPWildcardPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.pattern; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | 28 | public class DBSPWildcardPattern extends DBSPPattern { 29 | public static final DBSPWildcardPattern INSTANCE =new DBSPWildcardPattern(); 30 | 31 | private DBSPWildcardPattern() { 32 | super(null); 33 | } 34 | 35 | @Override 36 | public void accept(InnerVisitor visitor) { 37 | if (!visitor.preorder(this)) return; 38 | visitor.postorder(this); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/pattern/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.pattern; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/statement/DBSPExpressionStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.statement; 25 | 26 | import org.dbsp.sqlCompiler.ir.InnerVisitor; 27 | import org.dbsp.sqlCompiler.ir.expression.DBSPExpression; 28 | 29 | public class DBSPExpressionStatement extends DBSPStatement { 30 | public final DBSPExpression expression; 31 | 32 | public DBSPExpressionStatement(DBSPExpression expression) { 33 | super(null); 34 | this.expression = expression; 35 | } 36 | 37 | @Override 38 | public void accept(InnerVisitor visitor) { 39 | if (!visitor.preorder(this)) return; 40 | this.expression.accept(visitor); 41 | visitor.postorder(this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/statement/DBSPStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.statement; 25 | 26 | import org.dbsp.sqlCompiler.circuit.DBSPNode; 27 | import org.dbsp.sqlCompiler.circuit.IDBSPInnerNode; 28 | 29 | import javax.annotation.Nullable; 30 | 31 | public abstract class DBSPStatement 32 | extends DBSPNode 33 | implements IDBSPInnerNode { 34 | @SuppressWarnings("SameParameterValue") 35 | protected DBSPStatement(@Nullable Object node) { 36 | super(node); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/statement/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.statement; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/DBSPTypeTupleBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.type; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public abstract class DBSPTypeTupleBase extends DBSPType { 29 | public final DBSPType[] tupFields; 30 | 31 | protected DBSPTypeTupleBase(@Nullable Object node, boolean mayBeNull, DBSPType... tupFields) { 32 | super(node, mayBeNull); 33 | this.tupFields = tupFields; 34 | } 35 | 36 | public DBSPType getFieldType(int index) { 37 | return this.tupFields[index]; 38 | } 39 | 40 | public int size() { 41 | return this.tupFields.length; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/ICollectionType.java: -------------------------------------------------------------------------------- 1 | package org.dbsp.sqlCompiler.ir.type; 2 | 3 | public interface ICollectionType { 4 | DBSPType getElementType(); 5 | } 6 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/IHasType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.type; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | /** 29 | * Interface implemented by all classes that have a type. 30 | */ 31 | public interface IHasType { 32 | @Nullable 33 | DBSPType getType(); 34 | 35 | default DBSPType getNonVoidType() { 36 | // void is represented as Java null. 37 | DBSPType type = this.getType(); 38 | if (type == null) 39 | throw new RuntimeException("Expected a non-void type"); 40 | return type; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/IsDateType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.type; 25 | 26 | /** 27 | * interface implemented by types that look like dates. 28 | */ 29 | public interface IsDateType {} 30 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/IsNumericType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.type; 25 | 26 | import org.dbsp.sqlCompiler.ir.expression.literal.DBSPLiteral; 27 | 28 | /** 29 | * Interface implemented by numeric types. 30 | */ 31 | public interface IsNumericType { 32 | default String getRustString() { return this.toString(); } 33 | DBSPLiteral getZero(); 34 | DBSPLiteral getOne(); 35 | DBSPLiteral getMaxValue(); 36 | DBSPLiteral getMinValue(); 37 | } 38 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.type; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/primitive/DBSPTypeGeo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.ir.type.primitive; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | /** 29 | * Base class for geographic data types. 30 | */ 31 | public abstract class DBSPTypeGeo extends DBSPTypeBaseType { 32 | protected DBSPTypeGeo(@Nullable Object node, boolean mayBeNull) { 33 | super(node, mayBeNull); 34 | } 35 | 36 | public boolean hasCopy() { 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/ir/type/primitive/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler.ir.type.primitive; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqlCompiler/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * Package that doesn't allow null values as method parameters. 26 | */ 27 | 28 | @ParametersAreNonnullByDefault 29 | @FieldsAreNonnullByDefault 30 | @MethodsAreNonnullByDefault 31 | package org.dbsp.sqlCompiler; 32 | 33 | import org.dbsp.util.FieldsAreNonnullByDefault; 34 | import org.dbsp.util.MethodsAreNonnullByDefault; 35 | 36 | import javax.annotation.ParametersAreNonnullByDefault; 37 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/AcceptancePolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.sqllogictest; 27 | 28 | import java.util.List; 29 | 30 | public interface AcceptancePolicy { 31 | /** 32 | * Returns true if a query is accepted. 33 | * @param skip List of dbs to skip. 34 | * @param only List of dbs to accept. 35 | */ 36 | boolean accept(List skip, List only); 37 | } 38 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/ISqlTestOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqllogictest; 25 | 26 | import org.dbsp.util.ICastable; 27 | 28 | /** 29 | * Base interface for SqlLogicTest operations: either statements or queries. 30 | */ 31 | public interface ISqlTestOperation extends ICastable { } 32 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an implementation that runs SQL Logic Tests against DBSP. 2 | See https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/SqlStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqllogictest; 25 | 26 | public class SqlStatement implements ISqlTestOperation { 27 | public final String statement; 28 | public final boolean shouldPass; 29 | 30 | public SqlStatement(String statement, boolean shouldPass) { 31 | this.statement = statement; 32 | this.shouldPass = shouldPass; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return this.statement; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/SqlStatementList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.sqllogictest; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | 31 | /** 32 | * A set of SQL statements. 33 | */ 34 | public class SqlStatementList { 35 | /** 36 | * List of SQL statements that are used to create tables. 37 | */ 38 | public final List statements; 39 | public SqlStatementList() { 40 | this.statements = new ArrayList<>(); 41 | } 42 | public void add(SqlStatement statement) { 43 | this.statements.add(statement); 44 | } 45 | public void clear() { this.statements.clear(); } 46 | public boolean contains(SqlStatement statement) { return this.statements.contains(statement); } 47 | } 48 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/SqlTestPrepareInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.sqllogictest; 27 | 28 | /** 29 | * A Set of Sql statements that insert or delete data from tables. 30 | */ 31 | public class SqlTestPrepareInput extends SqlStatementList {} 32 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/SqlTestPrepareTables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.sqllogictest; 27 | 28 | /** 29 | * A Set of Sql statements that insert or delete data from tables. 30 | */ 31 | public class SqlTestPrepareTables extends SqlStatementList {} 32 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/executors/SqlSLTTestExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqllogictest.executors; 25 | 26 | import org.apache.calcite.sql.parser.SqlParseException; 27 | import org.dbsp.sqllogictest.ExecutionOptions; 28 | import org.dbsp.sqllogictest.SLTTestFile; 29 | import org.dbsp.util.TestStatistics; 30 | 31 | import java.io.IOException; 32 | import java.security.NoSuchAlgorithmException; 33 | import java.sql.SQLException; 34 | 35 | public abstract class SqlSLTTestExecutor extends SqlTestExecutor { 36 | /** 37 | * Execute the specified test file. 38 | */ 39 | public abstract TestStatistics execute(SLTTestFile testFile, ExecutionOptions options) 40 | throws SqlParseException, IOException, SQLException, NoSuchAlgorithmException, InterruptedException; 41 | } 42 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/executors/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Package that doesn't allow null values as method parameters. 28 | */ 29 | 30 | @ParametersAreNonnullByDefault 31 | @FieldsAreNonnullByDefault 32 | @MethodsAreNonnullByDefault 33 | package org.dbsp.sqllogictest.executors; 34 | 35 | import org.dbsp.util.FieldsAreNonnullByDefault; 36 | import org.dbsp.util.MethodsAreNonnullByDefault; 37 | 38 | import javax.annotation.ParametersAreNonnullByDefault; 39 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/sqllogictest/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Package that doesn't allow null values as method parameters. 28 | */ 29 | 30 | @ParametersAreNonnullByDefault 31 | @FieldsAreNonnullByDefault 32 | @MethodsAreNonnullByDefault 33 | package org.dbsp.sqllogictest; 34 | 35 | import org.dbsp.util.FieldsAreNonnullByDefault; 36 | import org.dbsp.util.MethodsAreNonnullByDefault; 37 | 38 | import javax.annotation.ParametersAreNonnullByDefault; 39 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/FieldsAreNonnullByDefault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.util; 27 | 28 | import javax.annotation.Nonnull; 29 | import javax.annotation.meta.TypeQualifierDefault; 30 | import java.lang.annotation.Documented; 31 | import java.lang.annotation.ElementType; 32 | import java.lang.annotation.Retention; 33 | import java.lang.annotation.RetentionPolicy; 34 | 35 | /** 36 | * Applies the {@link Nonnull} annotation to every field unless overridden. 37 | */ 38 | @Documented 39 | @Nonnull 40 | @TypeQualifierDefault(ElementType.FIELD) 41 | @Retention(RetentionPolicy.RUNTIME) 42 | public @interface FieldsAreNonnullByDefault 43 | {} 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/IDebuggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.util; 25 | 26 | public interface IDebuggable { 27 | /** 28 | * Higher levels -> more debugging information. 29 | */ 30 | void setDebugLevel(String module, int level); 31 | 32 | default void setDebugLevel(Class clazz, int level) { 33 | this.setDebugLevel(clazz.getSimpleName(), level); 34 | } 35 | 36 | /** 37 | * The current debug level. 38 | */ 39 | int getDebugLevel(String module); 40 | 41 | /** 42 | * Stream that debugging information goes to. 43 | * @return The previous output stream. 44 | */ 45 | Appendable setDebugStream(Appendable writer); 46 | } 47 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/IHasName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.util; 25 | 26 | public interface IHasName { 27 | String getName(); 28 | } 29 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/IModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.util; 25 | 26 | /** 27 | * By inheriting this interface a Java class becomes a "module". 28 | * That's useful for logging, where logging is controlled per module. 29 | */ 30 | public interface IModule { 31 | /** 32 | * Gets the name of the current module. 33 | */ 34 | default String getModule() { 35 | return this.getClass().getSimpleName(); 36 | } 37 | 38 | /** 39 | * Get the debugging level of the current module. 40 | */ 41 | default int getDebugLevel() { 42 | return Logger.INSTANCE.getDebugLevel(this.getModule()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/IdGen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.util; 27 | 28 | /** 29 | * Base class for objects that have unique Ids. 30 | */ 31 | public class IdGen { 32 | static long idGen = 0; 33 | public final long id; 34 | 35 | public IdGen() { 36 | this.id = idGen++; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/MethodsAreNonnullByDefault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.util; 27 | 28 | import javax.annotation.Nonnull; 29 | import javax.annotation.meta.TypeQualifierDefault; 30 | import java.lang.annotation.Documented; 31 | import java.lang.annotation.ElementType; 32 | import java.lang.annotation.Retention; 33 | import java.lang.annotation.RetentionPolicy; 34 | 35 | /** 36 | * Applies the {@link Nonnull} annotation to every method unless overridden. 37 | */ 38 | @Documented 39 | @Nonnull 40 | @TypeQualifierDefault(ElementType.METHOD) 41 | @Retention(RetentionPolicy.RUNTIME) 42 | public @interface MethodsAreNonnullByDefault 43 | {} 44 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/ToIndentableString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.util; 25 | 26 | /** 27 | * Interface implemented by objects that can be as nicely indented strings. 28 | */ 29 | public interface ToIndentableString { 30 | IIndentStream toString(IIndentStream builder); 31 | } 32 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/TranslationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | package org.dbsp.util; 27 | 28 | import javax.annotation.Nullable; 29 | 30 | public class TranslationException extends RuntimeException { 31 | private static final long serialVersionUID = 1L; 32 | 33 | public TranslationException(String message, @Nullable Object node) { 34 | super(message + "\n" + getPosition(node)); 35 | } 36 | 37 | private static String getPosition(@Nullable Object node) { 38 | if (node == null) 39 | return ""; 40 | return node.toString(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SQL-compiler/src/main/java/org/dbsp/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Package that doesn't allow null values as method parameters. 28 | */ 29 | 30 | @ParametersAreNonnullByDefault 31 | @FieldsAreNonnullByDefault 32 | @MethodsAreNonnullByDefault 33 | package org.dbsp.util; 34 | 35 | import javax.annotation.ParametersAreNonnullByDefault; 36 | -------------------------------------------------------------------------------- /SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/OptimizedIncrementalTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | package org.dbsp.sqlCompiler.compiler; 25 | 26 | public class OptimizedIncrementalTests extends NaiveIncrementalTests { 27 | public void invokeTestQueryBase(String query, BaseSQLTests.InputOutputPair... streams) { 28 | super.testQueryBase(query, true, true, streams); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Package that doesn't allow null values as method parameters. 28 | */ 29 | 30 | @ParametersAreNonnullByDefault 31 | @FieldsAreNonnullByDefault 32 | @MethodsAreNonnullByDefault 33 | package org.dbsp.sqlCompiler.compiler; 34 | 35 | import org.dbsp.util.FieldsAreNonnullByDefault; 36 | import org.dbsp.util.MethodsAreNonnullByDefault; 37 | 38 | import javax.annotation.ParametersAreNonnullByDefault; 39 | -------------------------------------------------------------------------------- /SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/postgres/README.md: -------------------------------------------------------------------------------- 1 | The data for these tests was "stolen" from the postgres repository. 2 | 3 | Unfortunately it's too difficult to automatically run these files as is, since they contain many features very specific to postgres. -------------------------------------------------------------------------------- /SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/postgres/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 VMware, Inc. 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Package that doesn't allow null values as method parameters. 28 | */ 29 | 30 | @ParametersAreNonnullByDefault 31 | @FieldsAreNonnullByDefault 32 | @MethodsAreNonnullByDefault 33 | package org.dbsp.sqlCompiler.compiler.postgres; 34 | 35 | import org.dbsp.util.FieldsAreNonnullByDefault; 36 | import org.dbsp.util.MethodsAreNonnullByDefault; 37 | 38 | import javax.annotation.ParametersAreNonnullByDefault; 39 | -------------------------------------------------------------------------------- /SQL-compiler/x.sql: -------------------------------------------------------------------------------- 1 | -- example input file 2 | CREATE TABLE T(COL0 INTEGER, COL1 INTEGER); 3 | CREATE VIEW V AS SELECT T.COL1 FROM T; 4 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | _book/ 2 | *.pdf 3 | *.tex 4 | .DS_Store 5 | */.DS_Store 6 | *.sh 7 | private/ 8 | scripts/ 9 | systemsapproach.github.io/ 10 | _build/ 11 | venv-docs/ 12 | cover.docx 13 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for ONF documentation created with Sphinx 2 | 3 | # use bash for pushd/popd, and to fail quickly. virtualenv's activate 4 | # has undefined variables, so no -u 5 | SHELL = bash -e -o pipefail 6 | 7 | # You can set these variables from the command line. 8 | SPHINXOPTS ?= 9 | SPHINXBUILD ?= sphinx-build 10 | SOURCEDIR ?= . 11 | BUILDDIR ?= _build 12 | 13 | # Create the virtualenv with all the tools installed 14 | VIRTUALENV = venv-docs 15 | 16 | # Put it first so that "make" without argument is like "make help". 17 | help: $(VIRTUALENV) 18 | source ./$(VIRTUALENV)/bin/activate ;\ 19 | $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | 21 | .PHONY: help lint reload Makefile test 22 | 23 | # Create the virtualenv with all the tools installed 24 | $(VIRTUALENV): 25 | python3 -m venv $@ ;\ 26 | source ./$@/bin/activate ;\ 27 | pip install -r requirements.txt 28 | 29 | # lint and link verification. linkcheck is built into sphinx 30 | test: lint spelling linkcheck 31 | 32 | # lint all .rst files 33 | lint: $(VIRTUALENV) 34 | source ./$. 11 | 12 | The build process is stored in the `Makefile` and requires Python be 13 | installed. The `Makefile` will create a virtualenv (`venv-docs`) which 14 | installs the documentation generation toolset. You may also need to 15 | install the `enchant` C library using your system’s package manager 16 | for the spelling checker to function properly. 17 | 18 | To generate HTML in `_build/html`, run `make html`. 19 | 20 | To check the formatting of the book, run `make lint`. 21 | 22 | To check spelling, run `make spelling`. If there are additional 23 | words, names, or acronyms that are correctly spelled but not in the dictionary, 24 | please add them to the `dict.txt` file. 25 | 26 | To see the other available output formats, run `make`. 27 | 28 | On Apple silicon, if you get the exception ''The 'enchant' C library 29 | was not found and maybe needs to be installed'' when running the 30 | `make` commands, set the following environment variable first after 31 | installing enchant via `brew install enchant`: 32 | 33 | ``` 34 | PYENCHANT_LIBRARY_PATH=/opt/homebrew/lib/libenchant-2.2.dylib 35 | ``` 36 | -------------------------------------------------------------------------------- /doc/VERSION: -------------------------------------------------------------------------------- 1 | Version 0.1 -------------------------------------------------------------------------------- /doc/_static/css/rtd_theme_mods.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present Open Networking Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. */ 15 | 16 | /* Don't restrict content width on the RTD theme 17 | * from: https://stackoverflow.com/a/32898444 */ 18 | 19 | .wy-nav-content { 20 | max-width: none; 21 | } 22 | 23 | .wy-table-responsive table td, .wy-table-responsive table th { 24 | white-space: normal; 25 | } 26 | 27 | /* Colors for navigation */ 28 | 29 | .wy-side-nav-search, .wy-nav-top { 30 | background: #2F5597; 31 | } 32 | 33 | /* .wy-menu-vertical header,.wy-menu-vertical p.caption{color:#2F5597} */ 34 | 35 | .wy-menu-vertical header,.wy-menu-vertical p.caption{color:#6AB0DE} 36 | 37 | /* Headings */ 38 | h1, h2 { 39 | font-weight: bold; 40 | line-height: 1.25; 41 | color: #3279a8 42 | text-rendering: optimizeLegibility; 43 | } 44 | 45 | h3, h4, h5, h6 { 46 | margin-bottom: .5rem; 47 | font-style: italic; 48 | line-height: 1.25; 49 | color: #313131; 50 | text-rendering: optimizeLegibility; 51 | } 52 | 53 | h1 { 54 | margin-bottom: 2rem; 55 | font-size: 2rem; 56 | } 57 | 58 | h2 { 59 | margin-bottom: .5rem; 60 | margin-top: 1rem; 61 | font-size: 1.5rem; 62 | } 63 | 64 | h3 { 65 | margin-top: 1.5rem; 66 | font-size: 1.25rem; 67 | } 68 | 69 | .pop { 70 | color: #6AB0DE; 71 | font-style: italic; 72 | font-weight: bold; 73 | } 74 | -------------------------------------------------------------------------------- /doc/dict.txt: -------------------------------------------------------------------------------- 1 | TINYINT 2 | VARCHAR 3 | toolset 4 | virtualenv 5 | nullable 6 | nullability 7 | datatype 8 | unary 9 | underspecified 10 | customizable 11 | datatypes 12 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | A compiler from SQL to DBSP 2 | =========================== 3 | 4 | | 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :caption: Table of Contents 9 | 10 | intro.rst 11 | sql.rst 12 | -------------------------------------------------------------------------------- /doc/intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | Describe briefly DBSP and the SQL compiler. 5 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | Sphinx~=4.4.0 2 | doc8~=0.10.1 3 | docutils~=0.17.1 4 | reuse~=0.14.0 5 | sphinx-rtd-theme~=1.0.0 6 | sphinxcontrib-spelling~=7.3.2 7 | sphinx-multiversion~=0.2.4 8 | -------------------------------------------------------------------------------- /doc/sql.rst: -------------------------------------------------------------------------------- 1 | Supported SQL Constructs 2 | ======================== 3 | 4 | SQL as a language has been standardized for a long time. 5 | Unfortunately, the standard leaves underspecified many important 6 | behaviors. Thus each SQL implementation is slightly different. 7 | 8 | The SQL to DBSP compiler is implemented on top of the `Apache Calcite 9 | `_ infrastructure. While Calcite is a 10 | very flexible and customizable platform, it makes several choices 11 | regarding the SQL language semantics. Our implementation mostly 12 | follows these choices. This document describes specifics of our 13 | implementation. 14 | 15 | .. toctree:: 16 | :maxdepth: 2 17 | 18 | sql/structure.rst 19 | sql/types.rst 20 | sql/boolean.rst 21 | sql/comparisons.rst 22 | sql/integer.rst 23 | sql/float.rst 24 | sql/decimal.rst 25 | sql/fp.rst 26 | sql/string.rst 27 | sql/datetime.rst 28 | sql/array.rst 29 | -------------------------------------------------------------------------------- /doc/sql/comparisons.rst: -------------------------------------------------------------------------------- 1 | Comparison Operations 2 | ===================== 3 | 4 | The following operations can take operands with multiple data types 5 | but always return a Boolean value (sometimes nullable): 6 | 7 | .. list-table:: comparisons 8 | :header-rows: 1 9 | 10 | * - Operation 11 | - Definition 12 | - Observation 13 | * - ``=`` 14 | - equality test 15 | - 16 | * - ``<>`` 17 | - inequality test 18 | - 19 | * - ``>`` 20 | - greater than 21 | - 22 | * - ``<`` 23 | - less than 24 | - 25 | * - ``>=`` 26 | - greater or equal 27 | - 28 | * - ``<=`` 29 | - less or equal 30 | - 31 | * - ``IS NULL`` 32 | - true if operand is ``NULL`` 33 | - 34 | * - ``IS NOT NULL`` 35 | - true if operand is not ``NULL`` 36 | - 37 | * - ``<=>`` 38 | - equality check that treats ``NULL`` values as equal 39 | - result is not nullable 40 | * - ``IS DISTINCT FROM`` 41 | - check if two values are not equal, treating ``NULL`` as equal 42 | - result is not nullable; 43 | * - ``IS NOT DISTINCT FROM`` 44 | - check if two values are the same, treating ``NULL`` values as 45 | equal 46 | - result is not nullable; 47 | * - ``BETWEEN ... AND ...`` 48 | - ``x BETWEEN a AND b`` is the same as ``a <= x AND x <= b`` 49 | - inclusive at both endpoints 50 | * - ``NOT BETWEEN ... AND ...`` 51 | - The ``NOT`` of the previous operator 52 | - not inclusive at either endpoint 53 | * - ``... IN ...`` 54 | - checks whether value appears in a list or set 55 | - 56 | * - `` ANY SET`` 57 | - check if any of the values in a set compares properly 58 | - Example: 10 <= ANY (VALUES 10, 20, 30) 59 | * - `` ALL SET`` 60 | - check if all the values in a set compare properly 61 | - Example: 10 <= ALL (VALUES 10, 20, 30) 62 | * - ``EXISTS query`` 63 | - check whether query results has at least one row 64 | - 65 | * - ``UNIQUE query`` 66 | - check whether the result of a query contains no duplicates 67 | - ignores ``NULL`` values 68 | -------------------------------------------------------------------------------- /doc/sql/decimal.rst: -------------------------------------------------------------------------------- 1 | Decimal data type 2 | ================= 3 | 4 | A synonym for the ``decimal`` type is ``numeric``. 5 | 6 | A decimal number is characterized by two magnitudes: the *precision*, 7 | which his the total number of decimal digits represented, and the 8 | *scale*, which is the count of digits in the fractional part, to the 9 | right of the decimal point. For example, the number 3.1415 has a 10 | precision of 5 and a scale of 4. 11 | 12 | The type ``NUMERIC(precision, scale)`` specifies both precision and 13 | scale, both of which must be constants. 14 | 15 | The type ``NUMERIC(precision)`` is the same as ``NUMERIC(precision, 0)``. 16 | 17 | The type ``NUMERIC`` specifies no limits on either precision or scale, 18 | and thus will use the maximum supported values for both. 19 | 20 | The maximum precision supported is 128 binary digits (38 decimal 21 | digits). The maximum scale supported is 10 decimal digits. 22 | 23 | 24 | Operations available for the ``decimal`` type 25 | --------------------------------------------- 26 | 27 | The legal operations are ``+`` (plus, unary and binary), ``-`` (minus, 28 | unary and binary), ``*`` (multiplication), ``/`` (division), ``%`` 29 | (modulus). 30 | 31 | Division or modulus by zero return ``NULL``. 32 | 33 | Predefined functions on Decimal Values 34 | -------------------------------------- 35 | 36 | .. list-table:: Predefined functions on decimal values 37 | :header-rows: 1 38 | 39 | * - ``ROUND(value)`` 40 | - same as ``ROUND(value, 0)`` 41 | * - ``ROUND(value, digits)`` 42 | - where ``digits`` is an integer value. Round the value to the 43 | specified number of *decimal* digits after the decimal point. 44 | -------------------------------------------------------------------------------- /doc/sql/float.rst: -------------------------------------------------------------------------------- 1 | Floating point types 2 | ==================== 3 | 4 | We support standard IEEE 754 floating point types. 5 | 6 | ``double`` is a 64-bit standard FP value. 7 | 8 | ``float`` is a 32-bit standard FP value. 9 | 10 | Floating point values include special values, such as ``NaN`` (not a 11 | number), ``-Infinity``, and ``-Infinity``. An alternative spelling 12 | for ``-Infinity`` is ``-inf`, and an alternative spelling for 13 | ``Infinity`` is ``inf``. When written as SQL literals, these values 14 | have to be surrounded by simple quotes: ``'inf'``. 15 | 16 | Infinity plus any finite value equals Infinity, as does Infinity plus 17 | Infinity. Infinity minus ``Infinity`` yields ``NaN``. 18 | 19 | ``NaN`` (not a number) value is used to represent undefined results. 20 | An operation with a ``NaN`` input yields ``NaN``. The only exception 21 | is when the operation's output does not depend on the ``NaN`` value: 22 | an example is ``NaN`` raised to the zero power yields one. 23 | -------------------------------------------------------------------------------- /doc/sql/fp.rst: -------------------------------------------------------------------------------- 1 | Floating-point arithmetic 2 | ========================= 3 | 4 | We support the standard IEEE floating point datatypes ``FLOAT`` and 5 | ``DOUBLE``, including all their special values: `NAN`, `INFINITY`. 6 | 7 | TODO: How does NAN compare? 8 | -------------------------------------------------------------------------------- /doc/sql/integer.rst: -------------------------------------------------------------------------------- 1 | Integer Operations 2 | ================== 3 | 4 | There are four supported integer datatypes, ``TINYINT`` (8 bits), 5 | ``SMALLINT`` (16 bits), ``INTEGER`` (32 bits), and ``BIGINT`` (64 6 | bits). These are represented as two's complement values, and 7 | computations on these types obey the standard two's complement 8 | semantics, including overflow. 9 | 10 | The legal operations are ``+`` (plus, unary and binary), ``-`` (minus, 11 | unary and binary), ``*`` (multiplication), ``/`` (division), ``%`` 12 | (modulus). 13 | 14 | Division or modulus by zero return ``NULL``. 15 | 16 | SQL performs a range of implicit casts when operating on values with 17 | different types. 18 | 19 | TODO: document the implicit casts. 20 | 21 | Predefined functions on integer values 22 | -------------------------------------- 23 | 24 | .. list-table:: Predefined functions on integer values 25 | :header-rows: 1 26 | 27 | * - Function 28 | - Description 29 | * - ``ABS(value)`` 30 | - return absolute value. 31 | * - ``MOD(left, right)`` 32 | - integer modulus. Same as ``left % right``. 33 | 34 | Operations not supported 35 | ------------------------ 36 | 37 | Non-deterministic functions, such as ``RAND`` cannot be supported in 38 | DBSP. 39 | -------------------------------------------------------------------------------- /doc/sql/string.rst: -------------------------------------------------------------------------------- 1 | String operations 2 | ================= 3 | 4 | ``||`` is string concatenation. 5 | -------------------------------------------------------------------------------- /doc/sql/structure.rst: -------------------------------------------------------------------------------- 1 | High-level program structure 2 | ============================ 3 | 4 | DBSP only supports two kinds of SQL statements: table definition 5 | statements, and view definition statements. Each table definition 6 | becomes an input, and each view definition becomes an output. 7 | Here is an example program: 8 | 9 | ``` 10 | CREATE TABLE T(COL0 INTEGER, COL1 INTEGER); 11 | CREATE VIEW V AS SELECT T.COL1 FROM T; 12 | ``` 13 | -------------------------------------------------------------------------------- /lib/genlib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "genlib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | #dbsp = { path = "../../../database-stream-processor" } 8 | dbsp = { git = "https://github.com/vmware/database-stream-processor.git", default-features = false } 9 | -------------------------------------------------------------------------------- /lib/genlib/README.md: -------------------------------------------------------------------------------- 1 | This library is automatically generated. 2 | -------------------------------------------------------------------------------- /lib/hashing/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hashing" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | md5 = { version = "0.7.0" } 8 | sqlvalue = { path = "../sqlvalue" } 9 | #dbsp = { path = "../../../database-stream-processor.git" } 10 | dbsp = { git = "https://github.com/vmware/database-stream-processor.git", default-features = false } 11 | size-of = { version = "0.1.5", features = ["rust_decimal"] } 12 | -------------------------------------------------------------------------------- /lib/readers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "readers" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | tuple = { path = "../tuple" } 8 | sqlvalue = { path = "../sqlvalue" } 9 | serde = { version = "1.0", features = ["derive"] } 10 | csv = { version = "1.1" } 11 | #dbsp = { path = "../../../database-stream-processor.git", features = ["with-serde"] } 12 | dbsp = { git = "https://github.com/vmware/database-stream-processor.git", features = ["with-serde"], default-features = false } 13 | size-of = { version = "0.1.5", features = ["rust_decimal"] } 14 | sqlx = { version = "0.6", features = [ "runtime-async-std-native-tls", "sqlite", "postgres", "any" ] } 15 | async-std = { version = "1.12.0", features = ["attributes"]} -------------------------------------------------------------------------------- /lib/readers/src/test.csv: -------------------------------------------------------------------------------- 1 | true,Mihai,0 2 | false,Leonid,1 3 | true,Chase,2 4 | false,Gerd,3 5 | true,, 6 | false,Nina, 7 | true,,6 8 | -------------------------------------------------------------------------------- /lib/sqllib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sqllib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | dbsp = { git = "https://github.com/vmware/database-stream-processor.git" } 8 | #dbsp = { path = "../../../database-stream-processor.git" } 9 | sqlx = { version = "0.6.2" } 10 | rust_decimal = { version = "1.29", features = ["maths"] } 11 | geo = { version = "0.23" } 12 | geo-types = { version = "0.7" } 13 | size-of = { version = "0.1.5", features = ["rust_decimal"] } 14 | serde = { version = "1.0", features = ["derive"] } 15 | num = { version = "0.4.0" } 16 | chrono = { version = "0.4.23" } 17 | -------------------------------------------------------------------------------- /lib/sqllib/README.md: -------------------------------------------------------------------------------- 1 | This module contains Rust definitions for some functions needed to 2 | implement various SQL operations. Other functions are generated 3 | by the compiler. 4 | -------------------------------------------------------------------------------- /lib/sqllib/src/geopoint.rs: -------------------------------------------------------------------------------- 1 | // I cannot use the standard geopoint object because it doesn't implement Ord 2 | 3 | use dbsp::algebra::F64; 4 | use size_of::*; 5 | use ::serde::{Deserialize,Serialize}; 6 | use geo::EuclideanDistance; 7 | use geo::Point; 8 | 9 | #[derive(Default, Eq, Ord, Clone, Hash, PartialEq, PartialOrd, SizeOf, Serialize, Deserialize, Debug)] 10 | pub struct GeoPoint(F64, F64); 11 | 12 | impl GeoPoint { 13 | pub fn new(left: T, right: S) -> Self 14 | where 15 | F64: From, 16 | F64: From, 17 | { 18 | Self(F64::from(left), F64::from(right)) 19 | } 20 | 21 | pub fn to_point(self: &Self) -> Point 22 | { 23 | Point::new(self.0.into_inner(), self.1.into_inner()) 24 | } 25 | 26 | pub fn distance(self: &Self, other: &GeoPoint) -> F64 27 | { 28 | let left = self.to_point(); 29 | let right = other.to_point(); 30 | F64::from(left.euclidean_distance(&right)) 31 | } 32 | } 33 | 34 | pub fn make_geopoint_d_d(left: F64, right: F64) -> GeoPoint { 35 | GeoPoint::new(left, right) 36 | } 37 | 38 | pub fn make_geopointN_d_d(left: F64, right: F64) -> Option { 39 | Some(make_geopoint_d_d(left, right)) 40 | } 41 | 42 | pub fn make_geopointN_dN_d(left: Option, right: F64) -> Option { 43 | left.map(|x| make_geopoint_d_d(x, right)) 44 | } 45 | 46 | pub fn make_geopointN_d_dN(left: F64, right: Option) -> Option { 47 | right.map(|x| make_geopoint_d_d(left, x)) 48 | } 49 | 50 | pub fn make_geopointN_dN_dN(left: Option, right: Option) -> Option { 51 | match (left, right) { 52 | (None, _) => None, 53 | (_, None) => None, 54 | (Some(x), Some(y)) => make_geopointN_d_d(x, y), 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/sqlvalue/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sqlvalue" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | #dbsp = { path = "../../../database-stream-processor.git" } 8 | dbsp = { git = "https://github.com/vmware/database-stream-processor.git", default-features = false } 9 | rust_decimal = { version = "1.29" } 10 | sqllib = { path = "../sqllib" } 11 | -------------------------------------------------------------------------------- /lib/tuple/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tuple" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | serde = { version = "1.0", features = ["derive"] } 8 | sqlvalue = { path = "../sqlvalue" } 9 | -------------------------------------------------------------------------------- /lib/tuple/README.md: -------------------------------------------------------------------------------- 1 | Rust tuples only work up to 12 elements, but we may need arbitrarily many. 2 | This library has a set of macros to define such tuples. 3 | -------------------------------------------------------------------------------- /temp/.gitignore: -------------------------------------------------------------------------------- 1 | Cargo.lock 2 | # automatically generated 3 | src/test.rs 4 | target/ 5 | -------------------------------------------------------------------------------- /temp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "temp" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | dbsp = { git = "https://github.com/vmware/database-stream-processor.git", features = ["with-serde"], default-features = false } 8 | dbsp_adapters = { git = "https://github.com/vmware/database-stream-processor.git", default-features = false } 9 | #dbsp = { path = "../../database-stream-processor", features = ["with-serde"] } 10 | #dbsp_adapters = { path = "../../database-stream-processor/adapters" } 11 | tuple = { path = "../lib/tuple" } 12 | sqllib = { path = "../lib/sqllib" } 13 | sqlvalue = { path = "../lib/sqlvalue" } 14 | serde = { version = "1.0", features = ["derive"] } 15 | hashing = { path = "../lib/hashing" } 16 | compare = { version = "0.1.0" } 17 | genlib = { path = "../lib/genlib" } 18 | size-of = { version = "0.1.1" } 19 | readers = { path = "../lib/readers" } 20 | geo = { version = "0.23" } 21 | geo-types = { version = "0.7" } 22 | sqlx = { version = "0.6", features = [ "runtime-async-std-native-tls", "sqlite", "any" ] } 23 | rust_decimal = { version = "1.29" } 24 | 25 | [lib] 26 | path = "src/lib.rs" 27 | doctest = false 28 | 29 | # Incremental builds sometimes crash the compiler 30 | [profile.test] 31 | incremental = false 32 | # Without this in debug builds overflows cause panics 33 | overflow-checks = false 34 | -------------------------------------------------------------------------------- /temp/src/README.md: -------------------------------------------------------------------------------- 1 | Automatically-generated tests are written in this directory 2 | --------------------------------------------------------------------------------